Skip to content

Commit 17f6f77

Browse files
committed
Fix declaration emit for negative number property declarations
1 parent 871bdee commit 17f6f77

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4652,6 +4652,9 @@ namespace ts {
46524652
if (!isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
46534653
return `"${escapeString(name, CharacterCodes.doubleQuote)}"`;
46544654
}
4655+
if (isNumericLiteralName(name) && startsWith(name, "-")) {
4656+
return `[${name}]`;
4657+
}
46554658
return name;
46564659
}
46574660
if (nameType.flags & TypeFlags.UniqueESSymbol) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: es5
2+
// @declaration: true
3+
var v = {
4+
[-1]: {}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: es6
2+
// @declaration: true
3+
var v = {
4+
[-1]: {}
5+
}

0 commit comments

Comments
 (0)