Skip to content

Commit d40b1d0

Browse files
committed
EnumLiteralExpression name is no longer an AST node, bunch of linter errors are fixed
1 parent 303bf25 commit d40b1d0

File tree

7 files changed

+8
-16
lines changed

7 files changed

+8
-16
lines changed

src/compiler/binder.ts

-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ import {
8585
FunctionLikeDeclaration,
8686
GetAccessorDeclaration,
8787
getAssignedExpandoInitializer,
88-
getAssignedName,
8988
getAssignmentDeclarationKind,
9089
getAssignmentDeclarationPropertyAccessKind,
9190
getCombinedModifierFlags,
@@ -158,7 +157,6 @@ import {
158157
isEntityNameExpression,
159158
isEnumConst,
160159
isEnumLiteralExpression,
161-
isEnumTypeReference,
162160
isExportAssignment,
163161
isExportDeclaration,
164162
isExportsIdentifier,

src/compiler/checker.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -47104,6 +47104,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4710447104
const isConstEnum = isEnumConst(member.parent);
4710547105
const initializer = member.initializer!;
4710647106
const result = evaluate(initializer, member);
47107+
const isDecl = isEnumDeclaration(member.parent);
4710747108
if (result.value !== undefined) {
4710847109
if (isConstEnum && typeof result.value === "number" && !isFinite(result.value)) {
4710947110
error(
@@ -47117,7 +47118,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4711747118
error(
4711847119
initializer,
4711947120
Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
47120-
`${idText(member.parent.name)}.${getTextOfPropertyName(member.name)}`,
47121+
isDecl ? `${idText(member.parent.name)}.${getTextOfPropertyName(member.name)}` : `${member.parent.name}.${getTextOfPropertyName(member.name)}`,
4712147122
);
4712247123
}
4712347124
}

src/compiler/parser.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ import {
110110
getLeadingCommentRanges,
111111
getSpellingSuggestion,
112112
getTextOfNodeFromSourceText,
113-
getTokenPosOfNode,
114113
HasJSDoc,
115114
hasJSDocNodes,
116115
HasModifiers,
@@ -330,7 +329,6 @@ import {
330329
ScriptKind,
331330
ScriptTarget,
332331
SetAccessorDeclaration,
333-
setOriginalNode,
334332
setParent,
335333
setParentRecursive,
336334
setTextRange,
@@ -7097,7 +7095,7 @@ namespace Parser {
70977095

70987096
let variableDeclaration;
70997097
if (parseOptional(SyntaxKind.OpenParenToken)) {
7100-
variableDeclaration = parseVariableDeclaration() as VariableDeclaration;
7098+
variableDeclaration = parseVariableDeclaration();
71017099
parseExpected(SyntaxKind.CloseParenToken);
71027100
}
71037101
else {
@@ -8268,7 +8266,6 @@ namespace Parser {
82688266
// const MyEnum: enum = { name: value }
82698267
const pos = getNodePos();
82708268
const hasJSDoc = hasPrecedingJSDocComment();
8271-
const tokenIsIdentifier = isIdentifier();
82728269
const name = parsePropertyName();
82738270
let initializer: Expression | undefined;
82748271

src/compiler/transformers/ts.ts

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ import {
8686
isElementAccessExpression,
8787
isEntityName,
8888
isEnumConst,
89-
isEnumMember,
9089
isExportAssignment,
9190
isExportDeclaration,
9291
isExportOrDefaultModifier,
@@ -170,7 +169,6 @@ import {
170169
setInternalEmitFlags,
171170
setOriginalNode,
172171
setParent,
173-
setParentRecursive,
174172
setSourceMapRange,
175173
setSyntheticLeadingComments,
176174
setSyntheticTrailingComments,

src/compiler/utilities.ts

-2
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ import {
277277
isElementAccessExpression,
278278
isEnumDeclaration,
279279
isEnumLiteralDeclaration,
280-
isEnumLiteralExpression,
281280
isEnumMember,
282-
isEnumTypeReference,
283281
isExportAssignment,
284282
isExportDeclaration,
285283
isExpressionStatement,

src/compiler/visitorPublic.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1480,11 +1480,11 @@ const visitEachChildTable: VisitEachChildTable = {
14801480
);
14811481
},
14821482

1483-
[SyntaxKind.EnumLiteralExpression]: function visitEachChildOfEnumDeclaration(node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) {
1483+
[SyntaxKind.EnumLiteralExpression]: function visitEachChildOfEnumDeclaration(node, visitor, context, nodesVisitor, _tokenVisitor) {
14841484
return context.factory.updateEnumLiteralExpression(
14851485
node,
14861486
nodesVisitor(node.modifiers, visitor, isModifierLike),
1487-
Debug.checkDefined(nodeVisitor(node.name, visitor, isIdentifier)),
1487+
node.name,
14881488
nodesVisitor(node.members, visitor, isEnumMember),
14891489
);
14901490
},

tests/baselines/reference/api/typescript.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5454,7 +5454,7 @@ declare namespace ts {
54545454
readonly kind: SyntaxKind.EnumLiteralExpression;
54555455
readonly parent: VariableDeclaration;
54565456
readonly modifiers?: NodeArray<ModifierLike>;
5457-
readonly name: Identifier;
5457+
readonly name: __String;
54585458
readonly members: NodeArray<EnumMember>;
54595459
}
54605460
type EnumDeclarationType = EnumDeclaration | EnumLiteralExpression;
@@ -7711,8 +7711,8 @@ declare namespace ts {
77117711
updateTypeAliasDeclaration(node: TypeAliasDeclaration, modifiers: readonly ModifierLike[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration;
77127712
createEnumDeclaration(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration;
77137713
updateEnumDeclaration(node: EnumDeclaration, modifiers: readonly ModifierLike[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration;
7714-
createEnumLiteralExpression(modifiers: readonly ModifierLike[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumLiteralExpression;
7715-
updateEnumLiteralExpression(node: EnumLiteralExpression, modifiers: readonly ModifierLike[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumLiteralExpression;
7714+
createEnumLiteralExpression(modifiers: readonly ModifierLike[] | undefined, name: __String, members: readonly EnumMember[]): EnumLiteralExpression;
7715+
updateEnumLiteralExpression(node: EnumLiteralExpression, modifiers: readonly ModifierLike[] | undefined, name: __String, members: readonly EnumMember[]): EnumLiteralExpression;
77167716
createModuleDeclaration(modifiers: readonly ModifierLike[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration;
77177717
updateModuleDeclaration(node: ModuleDeclaration, modifiers: readonly ModifierLike[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration;
77187718
createModuleBlock(statements: readonly Statement[]): ModuleBlock;

0 commit comments

Comments
 (0)