@@ -25185,7 +25185,7 @@ namespace ts {
25185
25185
}
25186
25186
// In ambient enum declarations that specify no const modifier, enum member declarations that omit
25187
25187
// a value are considered computed members (as opposed to having auto-incremented values).
25188
- if (member.parent.flags & NodeFlags.Ambient && !isConst (member.parent)) {
25188
+ if (member.parent.flags & NodeFlags.Ambient && !isEnumConst (member.parent)) {
25189
25189
return undefined;
25190
25190
}
25191
25191
// If the member declaration specifies no value, the member is considered a constant enum member.
@@ -25201,7 +25201,7 @@ namespace ts {
25201
25201
25202
25202
function computeConstantValue(member: EnumMember): string | number | undefined {
25203
25203
const enumKind = getEnumKind(getSymbolOfNode(member.parent));
25204
- const isConstEnum = isConst (member.parent);
25204
+ const isConstEnum = isEnumConst (member.parent);
25205
25205
const initializer = member.initializer!;
25206
25206
const value = enumKind === EnumKind.Literal && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
25207
25207
if (value !== undefined) {
@@ -25336,7 +25336,7 @@ namespace ts {
25336
25336
25337
25337
computeEnumMemberValues(node);
25338
25338
25339
- const enumIsConst = isConst (node);
25339
+ const enumIsConst = isEnumConst (node);
25340
25340
if (compilerOptions.isolatedModules && enumIsConst && node.flags & NodeFlags.Ambient) {
25341
25341
error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided);
25342
25342
}
@@ -25353,7 +25353,7 @@ namespace ts {
25353
25353
if (enumSymbol.declarations.length > 1) {
25354
25354
// check that const is placed\omitted on all enum declarations
25355
25355
forEach(enumSymbol.declarations, decl => {
25356
- if (isConstEnumDeclaration (decl) !== enumIsConst) {
25356
+ if (isEnumDeclaration(decl) && isEnumConst (decl) !== enumIsConst) {
25357
25357
error(getNameOfDeclaration(decl), Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
25358
25358
}
25359
25359
});
@@ -27217,8 +27217,9 @@ namespace ts {
27217
27217
const symbol = getNodeLinks(node).resolvedSymbol;
27218
27218
if (symbol && (symbol.flags & SymbolFlags.EnumMember)) {
27219
27219
// inline property\index accesses only for const enums
27220
- if (isConstEnumDeclaration(symbol.valueDeclaration.parent)) {
27221
- return getEnumMemberValue(<EnumMember>symbol.valueDeclaration);
27220
+ const member = symbol.valueDeclaration as EnumMember;
27221
+ if (isEnumConst(member.parent)) {
27222
+ return getEnumMemberValue(member);
27222
27223
}
27223
27224
}
27224
27225
@@ -27372,7 +27373,7 @@ namespace ts {
27372
27373
}
27373
27374
27374
27375
function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean {
27375
- if (isConst (node)) {
27376
+ if (isVariableDeclaration(node) && isVarConst (node)) {
27376
27377
const type = getTypeOfSymbol(getSymbolOfNode(node));
27377
27378
return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral);
27378
27379
}
@@ -28677,7 +28678,7 @@ namespace ts {
28677
28678
if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) {
28678
28679
if (node.flags & NodeFlags.Ambient) {
28679
28680
if (node.initializer) {
28680
- if (isConst (node) && !node.type) {
28681
+ if (isVarConst (node) && !node.type) {
28681
28682
if (!isStringOrNumberLiteralExpression(node.initializer)) {
28682
28683
return grammarErrorOnNode(node.initializer, Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal);
28683
28684
}
@@ -28688,7 +28689,7 @@ namespace ts {
28688
28689
return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
28689
28690
}
28690
28691
}
28691
- if (node.initializer && !(isConst (node) && isStringOrNumberLiteralExpression(node.initializer))) {
28692
+ if (node.initializer && !(isVarConst (node) && isStringOrNumberLiteralExpression(node.initializer))) {
28692
28693
// Error on equals token which immediate precedes the initializer
28693
28694
const equalsTokenLength = "=".length;
28694
28695
return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
@@ -28698,7 +28699,7 @@ namespace ts {
28698
28699
if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) {
28699
28700
return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer);
28700
28701
}
28701
- if (isConst (node)) {
28702
+ if (isVarConst (node)) {
28702
28703
return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized);
28703
28704
}
28704
28705
}
@@ -28713,7 +28714,7 @@ namespace ts {
28713
28714
checkESModuleMarker(node.name);
28714
28715
}
28715
28716
28716
- const checkLetConstNames = (isLet(node) || isConst (node));
28717
+ const checkLetConstNames = (isLet(node) || isVarConst (node));
28717
28718
28718
28719
// 1. LexicalDeclaration : LetOrConst BindingList ;
28719
28720
// It is a Syntax Error if the BoundNames of BindingList contains "let".
@@ -28793,7 +28794,7 @@ namespace ts {
28793
28794
if (isLet(node.declarationList)) {
28794
28795
return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
28795
28796
}
28796
- else if (isConst (node.declarationList)) {
28797
+ else if (isVarConst (node.declarationList)) {
28797
28798
return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
28798
28799
}
28799
28800
}
0 commit comments