@@ -2705,11 +2705,19 @@ namespace ts {
27052705 return isStringLiteralLike ( node ) || isNumericLiteral ( node ) ;
27062706 }
27072707
2708+ export function isSignedNumericLiteral ( node : Node ) : node is PrefixUnaryExpression & { operand : NumericLiteral } {
2709+ return isPrefixUnaryExpression ( node ) && ( node . operator === SyntaxKind . PlusToken || node . operator === SyntaxKind . MinusToken ) && isNumericLiteral ( node . operand ) ;
2710+ }
2711+
27082712 /**
2709- * A declaration has a dynamic name if both of the following are true:
2710- * 1. The declaration has a computed property name
2711- * 2. The computed name is *not* expressed as Symbol.<name>, where name
2712- * is a property of the Symbol constructor that denotes a built in
2713+ * A declaration has a dynamic name if all of the following are true:
2714+ * 1. The declaration has a computed property name.
2715+ * 2. The computed name is *not* expressed as a StringLiteral.
2716+ * 3. The computed name is *not* expressed as a NumericLiteral.
2717+ * 4. The computed name is *not* expressed as a PlusToken or MinusToken
2718+ * immediately followed by a NumericLiteral.
2719+ * 5. The computed name is *not* expressed as `Symbol.<name>`, where `<name>`
2720+ * is a property of the Symbol constructor that denotes a built-in
27132721 * Symbol.
27142722 */
27152723 export function hasDynamicName ( declaration : Declaration ) : declaration is DynamicNamedDeclaration {
@@ -2720,6 +2728,7 @@ namespace ts {
27202728 export function isDynamicName ( name : DeclarationName ) : boolean {
27212729 return name . kind === SyntaxKind . ComputedPropertyName &&
27222730 ! isStringOrNumericLiteralLike ( name . expression ) &&
2731+ ! isSignedNumericLiteral ( name . expression ) &&
27232732 ! isWellKnownSymbolSyntactically ( name . expression ) ;
27242733 }
27252734
0 commit comments