TypeScript: Octal escape sequences should be a lexical/syntactic error in strict mode and ES5
The following code should be disallowed in strict mode and ES5:
"\5";
"\05";
"\55";
"\055";
This is disallowed by Annex B.1.2 of the EcmaScript 5 spec.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 1
- Comments: 21 (10 by maintainers)
Yeah, just give it a shot and see how it goes 👍🏻
List of things to do for resolving this:
parser.ts:// Octal literals are not allowed...scanner.ts:scanEscapeSequence()should add: but…types.ts:ContainsInvalidEscape = 1 << 11is defined here but it’s unused!TemplateLiteralLikeFlags = ContainsInvalidEscape⇒ this is fishy, probably should be its own valuebinder.ts:checkStrictModeNumericLiteraland make a similar checker for strings with theContainsInvalidEscapeflag.One decision to make is whether to allow octal escapes in TS when not producing strict-mode code. It would probably be easier to forbid them anyway (especially since they’re never allowed in template strings) but if not, then the scanner mode should also parse the octal escapes in case the output is not strict.