Description
TypeScript Version: 2.4.1
Code
"use strict"
console.log(`\x001`);
Expected behavior:
Produces code that prints a null character followed by 1.
Actual behavior:
Produces this code:
"use strict";
console.log("\01");
This crashes because \01
is an octal literal, which isn't allowed in strict mode.
Note that this TypeScript code fails in a similar way:
console.log(`\u00001`);
Context:
This came up when converting the decaffeinate test suite to TypeScript, and the test case was based on a test from the CoffeeScript test suite. The CoffeeScript test suite has lots of edge cases like this, so I don't necessarily think this bug is likely to come up in real production code, but still would be good to fix. I was able to work around the issue (diff), so it's not blocking me, but CoffeeScript and Babel handle this sort of thing, so would be good if TypeScript did as well.