@@ -410,6 +410,7 @@ namespace ts {
410410 const location = getParseTreeNode(locationIn);
411411 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
412412 },
413+ getTypeOfSymbol,
413414 getSymbolsOfParameterPropertyDeclaration: (parameterIn, parameterName) => {
414415 const parameter = getParseTreeNode(parameterIn, isParameter);
415416 if (parameter === undefined) return Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
@@ -6261,7 +6262,7 @@ namespace ts {
62616262 }
62626263 const rawName = unescapeLeadingUnderscores(symbol.escapedName);
62636264 const stringNamed = !!length(symbol.declarations) && every(symbol.declarations, isStringNamed);
6264- return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed , singleQuote);
6265+ return createPropertyNameNodeForIdentifierOrLiteral(rawName, getEmitScriptTarget(compilerOptions) , singleQuote, stringNamed );
62656266 }
62666267
62676268 // See getNameForSymbolFromNameType for a stringy equivalent
@@ -6276,20 +6277,14 @@ namespace ts {
62766277 if (isNumericLiteralName(name) && startsWith(name, "-")) {
62776278 return factory.createComputedPropertyName(factory.createNumericLiteral(+name));
62786279 }
6279- return createPropertyNameNodeForIdentifierOrLiteral(name);
6280+ return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions) );
62806281 }
62816282 if (nameType.flags & TypeFlags.UniqueESSymbol) {
62826283 return factory.createComputedPropertyName(symbolToExpression((nameType as UniqueESSymbolType).symbol, context, SymbolFlags.Value));
62836284 }
62846285 }
62856286 }
62866287
6287- function createPropertyNameNodeForIdentifierOrLiteral(name: string, stringNamed?: boolean, singleQuote?: boolean) {
6288- return isIdentifierText(name, getEmitScriptTarget(compilerOptions)) ? factory.createIdentifier(name) :
6289- !stringNamed && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) :
6290- factory.createStringLiteral(name, !!singleQuote);
6291- }
6292-
62936288 function cloneNodeBuilderContext(context: NodeBuilderContext): NodeBuilderContext {
62946289 const initial: NodeBuilderContext = { ...context };
62956290 // Make type parameters created within this context not consume the name outside this context
@@ -27050,31 +27045,6 @@ namespace ts {
2705027045 return isTypeAssignableToKind(checkComputedPropertyName(name), TypeFlags.NumberLike);
2705127046 }
2705227047
27053- function isNumericLiteralName(name: string | __String) {
27054- // The intent of numeric names is that
27055- // - they are names with text in a numeric form, and that
27056- // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
27057- // acquired by applying the abstract 'ToNumber' operation on the name's text.
27058- //
27059- // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
27060- // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
27061- //
27062- // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
27063- // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
27064- // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
27065- // because their 'ToString' representation is not equal to their original text.
27066- // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
27067- //
27068- // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
27069- // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
27070- // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
27071- //
27072- // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
27073- // This is desired behavior, because when indexing with them as numeric entities, you are indexing
27074- // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
27075- return (+name).toString() === name;
27076- }
27077-
2707827048 function checkComputedPropertyName(node: ComputedPropertyName): Type {
2707927049 const links = getNodeLinks(node.expression);
2708027050 if (!links.resolvedType) {
0 commit comments