@@ -2705,11 +2705,19 @@ namespace ts {
2705
2705
return isStringLiteralLike ( node ) || isNumericLiteral ( node ) ;
2706
2706
}
2707
2707
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
+
2708
2712
/**
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
2713
2721
* Symbol.
2714
2722
*/
2715
2723
export function hasDynamicName ( declaration : Declaration ) : declaration is DynamicNamedDeclaration {
@@ -2720,6 +2728,7 @@ namespace ts {
2720
2728
export function isDynamicName ( name : DeclarationName ) : boolean {
2721
2729
return name . kind === SyntaxKind . ComputedPropertyName &&
2722
2730
! isStringOrNumericLiteralLike ( name . expression ) &&
2731
+ ! isSignedNumericLiteral ( name . expression ) &&
2723
2732
! isWellKnownSymbolSyntactically ( name . expression ) ;
2724
2733
}
2725
2734
0 commit comments