TypeScript/tests/cases/conformance/scanner/ecmascript5/scannerUnicodeEscapeInKeyword2.ts
Wesley Wigham 4ab85bbf35
Add error message for keywords with escapes in them (#32718)
* Add error message for keywords with escapes in them

* Move check into parser during advance to next token to utilize context for contextual keywords

* git add .

* Add tests for extended escapes

* Better error courtesy of @DanielRossenwaser

* Add test of browser-inconsistent case and alter condition to match spec

* Merge adjacent conditions

* Use seperate functions for checking keywords vs not

* Use flags to track unicode escape presence

* Adjust error text
2019-08-12 16:00:38 -07:00

39 lines
843 B
TypeScript

// @target: esnext
// @filename: file1.ts
var \u0061wait = 12; // ok
async function main() {
\u0061wait 12; // not ok
}
var \u0079ield = 12; // ok
function *gen() {
\u0079ield 12; //not ok
}
type typ\u0065 = 12; // ok
typ\u0065 notok = 0; // not ok
export {};
// @filename: file2.ts
\u{0076}ar x = "hello"; // not ok
var \u{0061}wait = 12; // ok
async function main() {
\u{0061}wait 12; // not ok
}
var \u{0079}ield = 12; // ok
function *gen() {
\u{0079}ield 12; //not ok
}
type typ\u{0065} = 12; // ok
typ\u{0065} notok = 0; // not ok
export {};
const a = {def\u0061ult: 12}; // OK, `default` not in keyword position
// chrome and jsc may still error on this, ref https://bugs.chromium.org/p/chromium/issues/detail?id=993000 and https://bugs.webkit.org/show_bug.cgi?id=200638