Skip to content

Commit fea1656

Browse files
authored
Emit numeric literal separators (microsoft#456)
1 parent 712f073 commit fea1656

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

internal/printer/printer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,13 +833,13 @@ func (p *Printer) emitLiteral(node *ast.LiteralLikeNode, flags getLiteralTextFla
833833

834834
func (p *Printer) emitNumericLiteral(node *ast.NumericLiteral) {
835835
p.enterNode(node.AsNode())
836-
p.emitLiteral(node.AsNode(), getLiteralTextFlagsNone)
836+
p.emitLiteral(node.AsNode(), getLiteralTextFlagsAllowNumericSeparator)
837837
p.exitNode(node.AsNode())
838838
}
839839

840840
func (p *Printer) emitBigIntLiteral(node *ast.BigIntLiteral) {
841841
p.enterNode(node.AsNode())
842-
p.emitLiteral(node.AsNode(), getLiteralTextFlagsNone)
842+
p.emitLiteral(node.AsNode(), getLiteralTextFlagsNone) // TODO: Preserve numeric literal separators after Strada migration
843843
p.exitNode(node.AsNode())
844844
}
845845

internal/printer/printer_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ func TestEmit(t *testing.T) {
2121
}{
2222
{title: "StringLiteral#1", input: `;"test"`, output: ";\n\"test\";"},
2323
{title: "StringLiteral#2", input: `;'test'`, output: ";\n'test';"},
24-
{title: "NumericLiteral", input: `0`, output: `0;`},
25-
{title: "BigIntLiteral", input: `0n`, output: `0n;`},
24+
{title: "NumericLiteral#1", input: `0`, output: `0;`},
25+
{title: "NumericLiteral#2", input: `10_000`, output: `10_000;`},
26+
{title: "BigIntLiteral#1", input: `0n`, output: `0n;`},
27+
{title: "BigIntLiteral#2", input: `10_000n`, output: `10000n;`}, // TODO: Preserve numeric literal separators after Strada migration
2628
{title: "BooleanLiteral#1", input: `true`, output: `true;`},
2729
{title: "BooleanLiteral#2", input: `false`, output: `false;`},
2830
{title: "NoSubstitutionTemplateLiteral", input: "``", output: "``;"},

0 commit comments

Comments
 (0)