Skip to content

Commit 34312af

Browse files
committed
attempt to make getTypeFromTypeReference changes easier to read
but it adds a bunch of casting, which isn't great
1 parent 380c082 commit 34312af

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/compiler/checker.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ import {
541541
isEnumLiteralExpression,
542542
isEnumMember,
543543
isEnumTypeAnnotation,
544-
isEnumTypeReference,
545544
isExclusivelyTypeOnlyImportOrExport,
546545
isExpandoPropertyDeclaration,
547546
isExportAssignment,
@@ -16712,8 +16711,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1671216711
return links.resolvedType = checkExpressionCached(node.parent.expression);
1671316712
}
1671416713
// `var MyEnum: enum = { FirstValue: 1, SecondValue: 2 }` should resolve to a union of the enum values.
16715-
if (isEnumTypeReference(node) && isVariableDeclaration(node.parent) && node.parent.initializer && isEnumLiteralExpression(node.parent.initializer)) {
16716-
return links.resolvedType = checkExpressionCached(node.parent.initializer);
16714+
if (node.parent && isEnumLiteralDeclaration(node.parent)) {
16715+
return links.resolvedType = checkExpressionCached((node.parent as VariableDeclaration).initializer as Expression);
1671716716
}
1671816717
let symbol: Symbol | undefined;
1671916718
let type: Type | undefined;
@@ -44140,7 +44139,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4414044139
checkClassNameCollisionWithObject(name);
4414144140
}
4414244141
}
44143-
else if (isEnumDeclaration(node) || (isVariableDeclaration(node) && node.initializer && isEnumLiteralExpression(node.initializer))) {
44142+
else if (isEnumDeclaration(node) || isEnumLiteralDeclaration(node)) {
4414444143
checkTypeNameIsReserved(name, Diagnostics.Enum_name_cannot_be_0);
4414544144
}
4414644145
}

0 commit comments

Comments
 (0)