From 77d71094cf2edb05b24fe962c603a4988d91b604 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 07:19:13 +0000 Subject: [PATCH 1/7] Add tests for identifiers and private identifiers with escape sequences. --- .../privateNamesEscapeSequences01.ts | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNamesEscapeSequences01.ts diff --git a/tests/cases/conformance/classes/members/privateNames/privateNamesEscapeSequences01.ts b/tests/cases/conformance/classes/members/privateNames/privateNamesEscapeSequences01.ts new file mode 100644 index 0000000000000..d651ab7cd6e1a --- /dev/null +++ b/tests/cases/conformance/classes/members/privateNames/privateNamesEscapeSequences01.ts @@ -0,0 +1,105 @@ +// @target: es5,es2015 + +// @filename: IdentifierNameWithEscape1.ts +export class IdentifierNameWithEscape1 { + \u0078: number; + + constructor() { + this.\u0078 = 0; + } + + doThing() { + this.x = 42; + } +} + +// @filename: IdentifierNameWithEscape2.ts +export class IdentifierNameWithEscape2 { + x\u0078: number; + + constructor() { + this.x\u0078 = 0; + } + + doThing() { + this.xx = 42; + } +} + +// @filename: IdentifierNameWithExtendedEscape1.ts +export class IdentifierNameWithExtendedEscape1 { + \u{78}: number; + + constructor() { + this.\u{78} = 0; + } + + doThing() { + this.x = 42; + } +} + +// @filename: IdentifierNameWithExtendedEscape2.ts +export class IdentifierNameWithExtendedEscape2 { + x\u{78}: number; + + constructor() { + this.x\u{78} = 0; + } + + doThing() { + this.xx = 42; + } +} + +// @filename: PrivateIdentifierNameWithEscape1.ts +export class PrivateIdentifierWithEscape1 { + #\u0078: number; + + constructor() { + this.#\u0078 = 0; + } + + doThing() { + this.#x = 42; + } +} + +// @filename: PrivateIdentifierNameWithEscape2.ts +export class PrivateIdentifierWithEscape2 { + #x\u0078: number; + + constructor() { + this.#x\u0078 = 0; + } + + doThing() { + this.#xx = 42; + } +} + +// @filename: PrivateIdentifierNameWithExtendedEscape1.ts +export class PrivateIdentifierWithExtendedEscape1 { + #\u{78}: number; + + constructor() { + this.#\u{78} = 0; + } + + doThing() { + this.#x = 42; + } +} + +// @filename: PrivateIdentifierNameWithExtendedEscape2.ts +export class PrivateIdentifierWithExtendedEscape2 { + #x\u{78}: number; + + constructor() { + this.#x\u{78} = 0; + } + + doThing() { + this.#xx = 42; + } +} From 3f8b934f0f820360542c000116cdb889e3f150d3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 07:19:32 +0000 Subject: [PATCH 2/7] Accepted baselines. --- ...scapeSequences01(target=es2015).errors.txt | 148 ++++++++ ...teNamesEscapeSequences01(target=es2015).js | 215 ++++++++++++ ...esEscapeSequences01(target=es2015).symbols | 182 ++++++++++ ...amesEscapeSequences01(target=es2015).types | 220 ++++++++++++ ...esEscapeSequences01(target=es5).errors.txt | 328 ++++++++++++++++++ ...ivateNamesEscapeSequences01(target=es5).js | 295 ++++++++++++++++ ...NamesEscapeSequences01(target=es5).symbols | 158 +++++++++ ...teNamesEscapeSequences01(target=es5).types | 249 +++++++++++++ 8 files changed, 1795 insertions(+) create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols create mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt new file mode 100644 index 0000000000000..1c21527bbff9e --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt @@ -0,0 +1,148 @@ +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,5): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,6): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,14): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(9,14): error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,6): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,14): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS2663: Cannot find name '\u{78}'. Did you mean the instance member 'this.\u{78}'? +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithExtendedEscape1'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(9,14): error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithExtendedEscape2'. + + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts (0 errors) ==== + export class IdentifierNameWithEscape1 { + \u0078: number; + + constructor() { + this.\u0078 = 0; + } + + doThing() { + this.x = 42; + } + } + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts (0 errors) ==== + export class IdentifierNameWithEscape2 { + x\u0078: number; + + constructor() { + this.x\u0078 = 0; + } + + doThing() { + this.xx = 42; + } + } + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts (0 errors) ==== + export class IdentifierNameWithExtendedEscape1 { + \u{78}: number; + + constructor() { + this.\u{78} = 0; + } + + doThing() { + this.x = 42; + } + } + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts (0 errors) ==== + export class IdentifierNameWithExtendedEscape2 { + x\u{78}: number; + + constructor() { + this.x\u{78} = 0; + } + + doThing() { + this.xx = 42; + } + } + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts (6 errors) ==== + export class PrivateIdentifierWithEscape1 { + #\u0078: number; + ~ +!!! error TS1127: Invalid character. + ~~~~~~ +!!! error TS1005: ';' expected. + + constructor() { + this.#\u0078 = 0; + ~ +!!! error TS1127: Invalid character. + ~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~ +!!! error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? + } + + doThing() { + this.#x = 42; + ~~ +!!! error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. + } + } + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (1 errors) ==== + export class PrivateIdentifierWithEscape2 { + #x\u0078: number; + + constructor() { + this.#x\u0078 = 0; + } + + doThing() { + this.#xx = 42; + ~~~ +!!! error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. + } + } + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts (6 errors) ==== + export class PrivateIdentifierWithExtendedEscape1 { + #\u{78}: number; + ~ +!!! error TS1127: Invalid character. + ~~~~~~ +!!! error TS1005: ';' expected. + + constructor() { + this.#\u{78} = 0; + ~ +!!! error TS1127: Invalid character. + ~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~ +!!! error TS2663: Cannot find name '\u{78}'. Did you mean the instance member 'this.\u{78}'? + } + + doThing() { + this.#x = 42; + ~~ +!!! error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithExtendedEscape1'. + } + } + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts (1 errors) ==== + export class PrivateIdentifierWithExtendedEscape2 { + #x\u{78}: number; + + constructor() { + this.#x\u{78} = 0; + } + + doThing() { + this.#xx = 42; + ~~~ +!!! error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithExtendedEscape2'. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js new file mode 100644 index 0000000000000..953ab7a7feb0e --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js @@ -0,0 +1,215 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNamesEscapeSequences01.ts] //// + +//// [IdentifierNameWithEscape1.ts] +export class IdentifierNameWithEscape1 { + \u0078: number; + + constructor() { + this.\u0078 = 0; + } + + doThing() { + this.x = 42; + } +} + +//// [IdentifierNameWithEscape2.ts] +export class IdentifierNameWithEscape2 { + x\u0078: number; + + constructor() { + this.x\u0078 = 0; + } + + doThing() { + this.xx = 42; + } +} + +//// [IdentifierNameWithExtendedEscape1.ts] +export class IdentifierNameWithExtendedEscape1 { + \u{78}: number; + + constructor() { + this.\u{78} = 0; + } + + doThing() { + this.x = 42; + } +} + +//// [IdentifierNameWithExtendedEscape2.ts] +export class IdentifierNameWithExtendedEscape2 { + x\u{78}: number; + + constructor() { + this.x\u{78} = 0; + } + + doThing() { + this.xx = 42; + } +} + +//// [PrivateIdentifierNameWithEscape1.ts] +export class PrivateIdentifierWithEscape1 { + #\u0078: number; + + constructor() { + this.#\u0078 = 0; + } + + doThing() { + this.#x = 42; + } +} + +//// [PrivateIdentifierNameWithEscape2.ts] +export class PrivateIdentifierWithEscape2 { + #x\u0078: number; + + constructor() { + this.#x\u0078 = 0; + } + + doThing() { + this.#xx = 42; + } +} + +//// [PrivateIdentifierNameWithExtendedEscape1.ts] +export class PrivateIdentifierWithExtendedEscape1 { + #\u{78}: number; + + constructor() { + this.#\u{78} = 0; + } + + doThing() { + this.#x = 42; + } +} + +//// [PrivateIdentifierNameWithExtendedEscape2.ts] +export class PrivateIdentifierWithExtendedEscape2 { + #x\u{78}: number; + + constructor() { + this.#x\u{78} = 0; + } + + doThing() { + this.#xx = 42; + } +} + + +//// [IdentifierNameWithEscape1.js] +export class IdentifierNameWithEscape1 { + constructor() { + this.\u0078 = 0; + } + doThing() { + this.x = 42; + } +} +//// [IdentifierNameWithEscape2.js] +export class IdentifierNameWithEscape2 { + constructor() { + this.x\u0078 = 0; + } + doThing() { + this.xx = 42; + } +} +//// [IdentifierNameWithExtendedEscape1.js] +export class IdentifierNameWithExtendedEscape1 { + constructor() { + this.\u{78} = 0; + } + doThing() { + this.x = 42; + } +} +//// [IdentifierNameWithExtendedEscape2.js] +export class IdentifierNameWithExtendedEscape2 { + constructor() { + this.x\u{78} = 0; + } + doThing() { + this.xx = 42; + } +} +//// [PrivateIdentifierNameWithEscape1.js] +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _PrivateIdentifierWithEscape1_; +export class PrivateIdentifierWithEscape1 { + constructor() { + _PrivateIdentifierWithEscape1_.set(this, void 0); + __classPrivateFieldGet(this, _PrivateIdentifierWithEscape1_, "f"); + \u0078 = 0; + } + doThing() { + this. = 42; + } +} +_PrivateIdentifierWithEscape1_ = new WeakMap(); +//// [PrivateIdentifierNameWithEscape2.js] +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var _PrivateIdentifierWithEscape2_x\u0078; +export class PrivateIdentifierWithEscape2 { + constructor() { + _PrivateIdentifierWithEscape2_x\u0078.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_x\u0078, 0, "f"); + } + doThing() { + this. = 42; + } +} +_PrivateIdentifierWithEscape2_x\u0078 = new WeakMap(); +//// [PrivateIdentifierNameWithExtendedEscape1.js] +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _PrivateIdentifierWithExtendedEscape1_; +export class PrivateIdentifierWithExtendedEscape1 { + constructor() { + _PrivateIdentifierWithExtendedEscape1_.set(this, void 0); + __classPrivateFieldGet(this, _PrivateIdentifierWithExtendedEscape1_, "f"); + \u{78} = 0; + } + doThing() { + this. = 42; + } +} +_PrivateIdentifierWithExtendedEscape1_ = new WeakMap(); +//// [PrivateIdentifierNameWithExtendedEscape2.js] +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var _PrivateIdentifierWithExtendedEscape2_x\u{78}; +export class PrivateIdentifierWithExtendedEscape2 { + constructor() { + _PrivateIdentifierWithExtendedEscape2_x\u{78}.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithExtendedEscape2_x\u{78}, 0, "f"); + } + doThing() { + this. = 42; + } +} +_PrivateIdentifierWithExtendedEscape2_x\u{78} = new WeakMap(); diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols new file mode 100644 index 0000000000000..f67c00ae4bec5 --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols @@ -0,0 +1,182 @@ +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts === +export class IdentifierNameWithEscape1 { +>IdentifierNameWithEscape1 : Symbol(IdentifierNameWithEscape1, Decl(IdentifierNameWithEscape1.ts, 0, 0)) + + \u0078: number; +>\u0078 : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) + + constructor() { + this.\u0078 = 0; +>this.\u0078 : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape1, Decl(IdentifierNameWithEscape1.ts, 0, 0)) +>\u0078 : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) + } + + doThing() { +>doThing : Symbol(IdentifierNameWithEscape1.doThing, Decl(IdentifierNameWithEscape1.ts, 5, 5)) + + this.x = 42; +>this.x : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape1, Decl(IdentifierNameWithEscape1.ts, 0, 0)) +>x : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts === +export class IdentifierNameWithEscape2 { +>IdentifierNameWithEscape2 : Symbol(IdentifierNameWithEscape2, Decl(IdentifierNameWithEscape2.ts, 0, 0)) + + x\u0078: number; +>x\u0078 : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) + + constructor() { + this.x\u0078 = 0; +>this.x\u0078 : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape2, Decl(IdentifierNameWithEscape2.ts, 0, 0)) +>x\u0078 : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) + } + + doThing() { +>doThing : Symbol(IdentifierNameWithEscape2.doThing, Decl(IdentifierNameWithEscape2.ts, 5, 5)) + + this.xx = 42; +>this.xx : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape2, Decl(IdentifierNameWithEscape2.ts, 0, 0)) +>xx : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts === +export class IdentifierNameWithExtendedEscape1 { +>IdentifierNameWithExtendedEscape1 : Symbol(IdentifierNameWithExtendedEscape1, Decl(IdentifierNameWithExtendedEscape1.ts, 0, 0)) + + \u{78}: number; +>\u{78} : Symbol(IdentifierNameWithExtendedEscape1[\u{78}], Decl(IdentifierNameWithExtendedEscape1.ts, 0, 48)) + + constructor() { + this.\u{78} = 0; +>this.\u{78} : Symbol(IdentifierNameWithExtendedEscape1[\u{78}], Decl(IdentifierNameWithExtendedEscape1.ts, 0, 48)) +>this : Symbol(IdentifierNameWithExtendedEscape1, Decl(IdentifierNameWithExtendedEscape1.ts, 0, 0)) +>\u{78} : Symbol(IdentifierNameWithExtendedEscape1[\u{78}], Decl(IdentifierNameWithExtendedEscape1.ts, 0, 48)) + } + + doThing() { +>doThing : Symbol(IdentifierNameWithExtendedEscape1.doThing, Decl(IdentifierNameWithExtendedEscape1.ts, 5, 5)) + + this.x = 42; +>this.x : Symbol(IdentifierNameWithExtendedEscape1[\u{78}], Decl(IdentifierNameWithExtendedEscape1.ts, 0, 48)) +>this : Symbol(IdentifierNameWithExtendedEscape1, Decl(IdentifierNameWithExtendedEscape1.ts, 0, 0)) +>x : Symbol(IdentifierNameWithExtendedEscape1[\u{78}], Decl(IdentifierNameWithExtendedEscape1.ts, 0, 48)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts === +export class IdentifierNameWithExtendedEscape2 { +>IdentifierNameWithExtendedEscape2 : Symbol(IdentifierNameWithExtendedEscape2, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 0)) + + x\u{78}: number; +>x\u{78} : Symbol(IdentifierNameWithExtendedEscape2.x\u{78}, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 48)) + + constructor() { + this.x\u{78} = 0; +>this.x\u{78} : Symbol(IdentifierNameWithExtendedEscape2.x\u{78}, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 48)) +>this : Symbol(IdentifierNameWithExtendedEscape2, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 0)) +>x\u{78} : Symbol(IdentifierNameWithExtendedEscape2.x\u{78}, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 48)) + } + + doThing() { +>doThing : Symbol(IdentifierNameWithExtendedEscape2.doThing, Decl(IdentifierNameWithExtendedEscape2.ts, 5, 5)) + + this.xx = 42; +>this.xx : Symbol(IdentifierNameWithExtendedEscape2.x\u{78}, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 48)) +>this : Symbol(IdentifierNameWithExtendedEscape2, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 0)) +>xx : Symbol(IdentifierNameWithExtendedEscape2.x\u{78}, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 48)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts === +export class PrivateIdentifierWithEscape1 { +>PrivateIdentifierWithEscape1 : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) + + #\u0078: number; +># : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) +>\u0078 : Symbol(PrivateIdentifierWithEscape1[\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 1, 5)) + + constructor() { + this.#\u0078 = 0; +>this.# : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) +>this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) + } + + doThing() { +>doThing : Symbol(PrivateIdentifierWithEscape1.doThing, Decl(PrivateIdentifierNameWithEscape1.ts, 5, 5)) + + this.#x = 42; +>this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts === +export class PrivateIdentifierWithEscape2 { +>PrivateIdentifierWithEscape2 : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) + + #x\u0078: number; +>#x\u0078 : Symbol(PrivateIdentifierWithEscape2.#x\u0078, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 43)) + + constructor() { + this.#x\u0078 = 0; +>this.#x\u0078 : Symbol(PrivateIdentifierWithEscape2.#x\u0078, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 43)) +>this : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) + } + + doThing() { +>doThing : Symbol(PrivateIdentifierWithEscape2.doThing, Decl(PrivateIdentifierNameWithEscape2.ts, 5, 5)) + + this.#xx = 42; +>this : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts === +export class PrivateIdentifierWithExtendedEscape1 { +>PrivateIdentifierWithExtendedEscape1 : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) + + #\u{78}: number; +># : Symbol(PrivateIdentifierWithExtendedEscape1[#], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) +>\u{78} : Symbol(PrivateIdentifierWithExtendedEscape1[\u{78}], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 1, 5)) + + constructor() { + this.#\u{78} = 0; +>this.# : Symbol(PrivateIdentifierWithExtendedEscape1[#], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) +>this : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) + } + + doThing() { +>doThing : Symbol(PrivateIdentifierWithExtendedEscape1.doThing, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 5, 5)) + + this.#x = 42; +>this : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts === +export class PrivateIdentifierWithExtendedEscape2 { +>PrivateIdentifierWithExtendedEscape2 : Symbol(PrivateIdentifierWithExtendedEscape2, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 0)) + + #x\u{78}: number; +>#x\u{78} : Symbol(PrivateIdentifierWithExtendedEscape2.#x\u{78}, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 51)) + + constructor() { + this.#x\u{78} = 0; +>this.#x\u{78} : Symbol(PrivateIdentifierWithExtendedEscape2.#x\u{78}, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 51)) +>this : Symbol(PrivateIdentifierWithExtendedEscape2, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 0)) + } + + doThing() { +>doThing : Symbol(PrivateIdentifierWithExtendedEscape2.doThing, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 5, 5)) + + this.#xx = 42; +>this : Symbol(PrivateIdentifierWithExtendedEscape2, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types new file mode 100644 index 0000000000000..fdcdd3ac35e38 --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types @@ -0,0 +1,220 @@ +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts === +export class IdentifierNameWithEscape1 { +>IdentifierNameWithEscape1 : IdentifierNameWithEscape1 + + \u0078: number; +>\u0078 : number + + constructor() { + this.\u0078 = 0; +>this.\u0078 = 0 : 0 +>this.\u0078 : number +>this : this +>\u0078 : number +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.x = 42; +>this.x = 42 : 42 +>this.x : number +>this : this +>x : number +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts === +export class IdentifierNameWithEscape2 { +>IdentifierNameWithEscape2 : IdentifierNameWithEscape2 + + x\u0078: number; +>x\u0078 : number + + constructor() { + this.x\u0078 = 0; +>this.x\u0078 = 0 : 0 +>this.x\u0078 : number +>this : this +>x\u0078 : number +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.xx = 42; +>this.xx = 42 : 42 +>this.xx : number +>this : this +>xx : number +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts === +export class IdentifierNameWithExtendedEscape1 { +>IdentifierNameWithExtendedEscape1 : IdentifierNameWithExtendedEscape1 + + \u{78}: number; +>\u{78} : number + + constructor() { + this.\u{78} = 0; +>this.\u{78} = 0 : 0 +>this.\u{78} : number +>this : this +>\u{78} : number +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.x = 42; +>this.x = 42 : 42 +>this.x : number +>this : this +>x : number +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts === +export class IdentifierNameWithExtendedEscape2 { +>IdentifierNameWithExtendedEscape2 : IdentifierNameWithExtendedEscape2 + + x\u{78}: number; +>x\u{78} : number + + constructor() { + this.x\u{78} = 0; +>this.x\u{78} = 0 : 0 +>this.x\u{78} : number +>this : this +>x\u{78} : number +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.xx = 42; +>this.xx = 42 : 42 +>this.xx : number +>this : this +>xx : number +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts === +export class PrivateIdentifierWithEscape1 { +>PrivateIdentifierWithEscape1 : PrivateIdentifierWithEscape1 + + #\u0078: number; +># : any +>\u0078 : number + + constructor() { + this.#\u0078 = 0; +>this.# : any +>this : this +>\u0078 = 0 : 0 +>\u0078 : any +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.#x = 42; +>this.#x = 42 : 42 +>this.#x : any +>this : this +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts === +export class PrivateIdentifierWithEscape2 { +>PrivateIdentifierWithEscape2 : PrivateIdentifierWithEscape2 + + #x\u0078: number; +>#x\u0078 : number + + constructor() { + this.#x\u0078 = 0; +>this.#x\u0078 = 0 : 0 +>this.#x\u0078 : number +>this : this +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.#xx = 42; +>this.#xx = 42 : 42 +>this.#xx : any +>this : this +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts === +export class PrivateIdentifierWithExtendedEscape1 { +>PrivateIdentifierWithExtendedEscape1 : PrivateIdentifierWithExtendedEscape1 + + #\u{78}: number; +># : any +>\u{78} : number + + constructor() { + this.#\u{78} = 0; +>this.# : any +>this : this +>\u{78} = 0 : 0 +>\u{78} : any +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.#x = 42; +>this.#x = 42 : 42 +>this.#x : any +>this : this +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts === +export class PrivateIdentifierWithExtendedEscape2 { +>PrivateIdentifierWithExtendedEscape2 : PrivateIdentifierWithExtendedEscape2 + + #x\u{78}: number; +>#x\u{78} : number + + constructor() { + this.#x\u{78} = 0; +>this.#x\u{78} = 0 : 0 +>this.#x\u{78} : number +>this : this +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.#xx = 42; +>this.#xx = 42 : 42 +>this.#xx : any +>this : this +>42 : 42 + } +} + diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt new file mode 100644 index 0000000000000..2e261efb997f3 --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt @@ -0,0 +1,328 @@ +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(2,6): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(2,7): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(2,11): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(2,13): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(4,5): error TS2304: Cannot find name 'constructor'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(4,19): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(5,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(5,14): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(5,15): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(5,15): error TS2304: Cannot find name 'u'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(5,21): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(8,5): error TS2304: Cannot find name 'doThing'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(8,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(9,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts(11,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(2,6): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(2,7): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(2,8): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(2,12): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(2,14): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(4,5): error TS2304: Cannot find name 'constructor'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(4,19): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(5,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(5,15): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(5,16): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(5,16): error TS2304: Cannot find name 'u'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(5,22): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(8,5): error TS2304: Cannot find name 'doThing'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(8,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(9,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(11,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,5): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,6): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,14): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(2,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(9,14): error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,6): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,7): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,8): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,12): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,14): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(4,5): error TS2304: Cannot find name 'constructor'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(4,19): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,14): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,16): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,16): error TS2304: Cannot find name 'u'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,22): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(8,5): error TS2304: Cannot find name 'doThing'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(8,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(9,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(11,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(2,7): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(2,8): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(2,9): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(2,13): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(2,15): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(4,5): error TS2304: Cannot find name 'constructor'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(4,19): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(5,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(5,16): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(5,17): error TS1434: Unexpected keyword or identifier. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(5,17): error TS2304: Cannot find name 'u'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(5,23): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(8,5): error TS2304: Cannot find name 'doThing'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(8,15): error TS1005: ';' expected. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(9,9): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(11,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts (0 errors) ==== + export class IdentifierNameWithEscape1 { + \u0078: number; + + constructor() { + this.\u0078 = 0; + } + + doThing() { + this.x = 42; + } + } + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts (0 errors) ==== + export class IdentifierNameWithEscape2 { + x\u0078: number; + + constructor() { + this.x\u0078 = 0; + } + + doThing() { + this.xx = 42; + } + } + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts (16 errors) ==== + export class IdentifierNameWithExtendedEscape1 { + \u{78}: number; + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + + constructor() { + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'constructor'. + ~ +!!! error TS1005: ';' expected. + this.\u{78} = 0; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS2304: Cannot find name 'u'. + ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + } + + doThing() { + ~~~~~~~ +!!! error TS2304: Cannot find name 'doThing'. + ~ +!!! error TS1005: ';' expected. + this.x = 42; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + ~ +!!! error TS1128: Declaration or statement expected. + +==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts (16 errors) ==== + export class IdentifierNameWithExtendedEscape2 { + x\u{78}: number; + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + + constructor() { + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'constructor'. + ~ +!!! error TS1005: ';' expected. + this.x\u{78} = 0; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS2304: Cannot find name 'u'. + ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + } + + doThing() { + ~~~~~~~ +!!! error TS2304: Cannot find name 'doThing'. + ~ +!!! error TS1005: ';' expected. + this.xx = 42; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + ~ +!!! error TS1128: Declaration or statement expected. + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts (6 errors) ==== + export class PrivateIdentifierWithEscape1 { + #\u0078: number; + ~ +!!! error TS1127: Invalid character. + ~~~~~~ +!!! error TS1005: ';' expected. + + constructor() { + this.#\u0078 = 0; + ~ +!!! error TS1127: Invalid character. + ~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~ +!!! error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? + } + + doThing() { + this.#x = 42; + ~~ +!!! error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. + } + } + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (2 errors) ==== + export class PrivateIdentifierWithEscape2 { + #x\u0078: number; + ~~~~~~~~ +!!! error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. + + constructor() { + this.#x\u0078 = 0; + } + + doThing() { + this.#xx = 42; + ~~~ +!!! error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. + } + } + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts (18 errors) ==== + export class PrivateIdentifierWithExtendedEscape1 { + #\u{78}: number; + ~ +!!! error TS1127: Invalid character. + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + + constructor() { + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'constructor'. + ~ +!!! error TS1005: ';' expected. + this.#\u{78} = 0; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + ~ +!!! error TS1127: Invalid character. + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS2304: Cannot find name 'u'. + ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + } + + doThing() { + ~~~~~~~ +!!! error TS2304: Cannot find name 'doThing'. + ~ +!!! error TS1005: ';' expected. + this.#x = 42; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + ~ +!!! error TS1128: Declaration or statement expected. + +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts (16 errors) ==== + export class PrivateIdentifierWithExtendedEscape2 { + #x\u{78}: number; + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + + constructor() { + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'constructor'. + ~ +!!! error TS1005: ';' expected. + this.#x\u{78} = 0; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + +!!! error TS1127: Invalid character. + ~ +!!! error TS1434: Unexpected keyword or identifier. + ~ +!!! error TS2304: Cannot find name 'u'. + ~ +!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses. + } + + doThing() { + ~~~~~~~ +!!! error TS2304: Cannot find name 'doThing'. + ~ +!!! error TS1005: ';' expected. + this.#xx = 42; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + ~ +!!! error TS1128: Declaration or statement expected. + \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js new file mode 100644 index 0000000000000..6c631bd49dd4a --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js @@ -0,0 +1,295 @@ +//// [tests/cases/conformance/classes/members/privateNames/privateNamesEscapeSequences01.ts] //// + +//// [IdentifierNameWithEscape1.ts] +export class IdentifierNameWithEscape1 { + \u0078: number; + + constructor() { + this.\u0078 = 0; + } + + doThing() { + this.x = 42; + } +} + +//// [IdentifierNameWithEscape2.ts] +export class IdentifierNameWithEscape2 { + x\u0078: number; + + constructor() { + this.x\u0078 = 0; + } + + doThing() { + this.xx = 42; + } +} + +//// [IdentifierNameWithExtendedEscape1.ts] +export class IdentifierNameWithExtendedEscape1 { + \u{78}: number; + + constructor() { + this.\u{78} = 0; + } + + doThing() { + this.x = 42; + } +} + +//// [IdentifierNameWithExtendedEscape2.ts] +export class IdentifierNameWithExtendedEscape2 { + x\u{78}: number; + + constructor() { + this.x\u{78} = 0; + } + + doThing() { + this.xx = 42; + } +} + +//// [PrivateIdentifierNameWithEscape1.ts] +export class PrivateIdentifierWithEscape1 { + #\u0078: number; + + constructor() { + this.#\u0078 = 0; + } + + doThing() { + this.#x = 42; + } +} + +//// [PrivateIdentifierNameWithEscape2.ts] +export class PrivateIdentifierWithEscape2 { + #x\u0078: number; + + constructor() { + this.#x\u0078 = 0; + } + + doThing() { + this.#xx = 42; + } +} + +//// [PrivateIdentifierNameWithExtendedEscape1.ts] +export class PrivateIdentifierWithExtendedEscape1 { + #\u{78}: number; + + constructor() { + this.#\u{78} = 0; + } + + doThing() { + this.#x = 42; + } +} + +//// [PrivateIdentifierNameWithExtendedEscape2.ts] +export class PrivateIdentifierWithExtendedEscape2 { + #x\u{78}: number; + + constructor() { + this.#x\u{78} = 0; + } + + doThing() { + this.#xx = 42; + } +} + + +//// [IdentifierNameWithEscape1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentifierNameWithEscape1 = void 0; +var IdentifierNameWithEscape1 = /** @class */ (function () { + function IdentifierNameWithEscape1() { + this.\u0078 = 0; + } + IdentifierNameWithEscape1.prototype.doThing = function () { + this.x = 42; + }; + return IdentifierNameWithEscape1; +}()); +exports.IdentifierNameWithEscape1 = IdentifierNameWithEscape1; +//// [IdentifierNameWithEscape2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentifierNameWithEscape2 = void 0; +var IdentifierNameWithEscape2 = /** @class */ (function () { + function IdentifierNameWithEscape2() { + this.x\u0078 = 0; + } + IdentifierNameWithEscape2.prototype.doThing = function () { + this.xx = 42; + }; + return IdentifierNameWithEscape2; +}()); +exports.IdentifierNameWithEscape2 = IdentifierNameWithEscape2; +//// [IdentifierNameWithExtendedEscape1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentifierNameWithExtendedEscape1 = void 0; +var IdentifierNameWithExtendedEscape1 = /** @class */ (function () { + function IdentifierNameWithExtendedEscape1() { + } + return IdentifierNameWithExtendedEscape1; +}()); +exports.IdentifierNameWithExtendedEscape1 = IdentifierNameWithExtendedEscape1; +{ + 78; +} +number; +constructor(); +{ + this.; + u; + { + 78; + } + 0; +} +doThing(); +{ + this.x = 42; +} +//// [IdentifierNameWithExtendedEscape2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentifierNameWithExtendedEscape2 = void 0; +var IdentifierNameWithExtendedEscape2 = /** @class */ (function () { + function IdentifierNameWithExtendedEscape2() { + } + return IdentifierNameWithExtendedEscape2; +}()); +exports.IdentifierNameWithExtendedEscape2 = IdentifierNameWithExtendedEscape2; +{ + 78; +} +number; +constructor(); +{ + this.x; + u; + { + 78; + } + 0; +} +doThing(); +{ + this.xx = 42; +} +//// [PrivateIdentifierNameWithEscape1.js] +"use strict"; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _PrivateIdentifierWithEscape1_; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrivateIdentifierWithEscape1 = void 0; +var PrivateIdentifierWithEscape1 = /** @class */ (function () { + function PrivateIdentifierWithEscape1() { + _PrivateIdentifierWithEscape1_.set(this, void 0); + __classPrivateFieldGet(this, _PrivateIdentifierWithEscape1_, "f"); + \u0078 = 0; + } + PrivateIdentifierWithEscape1.prototype.doThing = function () { + this. = 42; + }; + return PrivateIdentifierWithEscape1; +}()); +exports.PrivateIdentifierWithEscape1 = PrivateIdentifierWithEscape1; +_PrivateIdentifierWithEscape1_ = new WeakMap(); +//// [PrivateIdentifierNameWithEscape2.js] +"use strict"; +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var _PrivateIdentifierWithEscape2_x\u0078; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrivateIdentifierWithEscape2 = void 0; +var PrivateIdentifierWithEscape2 = /** @class */ (function () { + function PrivateIdentifierWithEscape2() { + _PrivateIdentifierWithEscape2_x\u0078.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_x\u0078, 0, "f"); + } + PrivateIdentifierWithEscape2.prototype.doThing = function () { + this. = 42; + }; + return PrivateIdentifierWithEscape2; +}()); +exports.PrivateIdentifierWithEscape2 = PrivateIdentifierWithEscape2; +_PrivateIdentifierWithEscape2_x\u0078 = new WeakMap(); +//// [PrivateIdentifierNameWithExtendedEscape1.js] +"use strict"; +var _PrivateIdentifierWithExtendedEscape1_; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrivateIdentifierWithExtendedEscape1 = void 0; +var PrivateIdentifierWithExtendedEscape1 = /** @class */ (function () { + function PrivateIdentifierWithExtendedEscape1() { + _PrivateIdentifierWithExtendedEscape1_.set(this, void 0); + } + return PrivateIdentifierWithExtendedEscape1; +}()); +exports.PrivateIdentifierWithExtendedEscape1 = PrivateIdentifierWithExtendedEscape1; +_PrivateIdentifierWithExtendedEscape1_ = new WeakMap(); +{ + 78; +} +number; +constructor(); +{ + this.; + u; + { + 78; + } + 0; +} +doThing(); +{ + this. = 42; +} +//// [PrivateIdentifierNameWithExtendedEscape2.js] +"use strict"; +var _PrivateIdentifierWithExtendedEscape2_x; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PrivateIdentifierWithExtendedEscape2 = void 0; +var PrivateIdentifierWithExtendedEscape2 = /** @class */ (function () { + function PrivateIdentifierWithExtendedEscape2() { + _PrivateIdentifierWithExtendedEscape2_x.set(this, void 0); + } + return PrivateIdentifierWithExtendedEscape2; +}()); +exports.PrivateIdentifierWithExtendedEscape2 = PrivateIdentifierWithExtendedEscape2; +_PrivateIdentifierWithExtendedEscape2_x = new WeakMap(); +{ + 78; +} +number; +constructor(); +{ + this.; + u; + { + 78; + } + 0; +} +doThing(); +{ + this. = 42; +} diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols new file mode 100644 index 0000000000000..0f1c15f985353 --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols @@ -0,0 +1,158 @@ +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts === +export class IdentifierNameWithEscape1 { +>IdentifierNameWithEscape1 : Symbol(IdentifierNameWithEscape1, Decl(IdentifierNameWithEscape1.ts, 0, 0)) + + \u0078: number; +>\u0078 : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) + + constructor() { + this.\u0078 = 0; +>this.\u0078 : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape1, Decl(IdentifierNameWithEscape1.ts, 0, 0)) +>\u0078 : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) + } + + doThing() { +>doThing : Symbol(IdentifierNameWithEscape1.doThing, Decl(IdentifierNameWithEscape1.ts, 5, 5)) + + this.x = 42; +>this.x : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape1, Decl(IdentifierNameWithEscape1.ts, 0, 0)) +>x : Symbol(IdentifierNameWithEscape1[\u0078], Decl(IdentifierNameWithEscape1.ts, 0, 40)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts === +export class IdentifierNameWithEscape2 { +>IdentifierNameWithEscape2 : Symbol(IdentifierNameWithEscape2, Decl(IdentifierNameWithEscape2.ts, 0, 0)) + + x\u0078: number; +>x\u0078 : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) + + constructor() { + this.x\u0078 = 0; +>this.x\u0078 : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape2, Decl(IdentifierNameWithEscape2.ts, 0, 0)) +>x\u0078 : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) + } + + doThing() { +>doThing : Symbol(IdentifierNameWithEscape2.doThing, Decl(IdentifierNameWithEscape2.ts, 5, 5)) + + this.xx = 42; +>this.xx : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) +>this : Symbol(IdentifierNameWithEscape2, Decl(IdentifierNameWithEscape2.ts, 0, 0)) +>xx : Symbol(IdentifierNameWithEscape2.x\u0078, Decl(IdentifierNameWithEscape2.ts, 0, 40)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts === +export class IdentifierNameWithExtendedEscape1 { +>IdentifierNameWithExtendedEscape1 : Symbol(IdentifierNameWithExtendedEscape1, Decl(IdentifierNameWithExtendedEscape1.ts, 0, 0)) + + \u{78}: number; +>u : Symbol(IdentifierNameWithExtendedEscape1.u, Decl(IdentifierNameWithExtendedEscape1.ts, 1, 5)) + + constructor() { + this.\u{78} = 0; + } + + doThing() { + this.x = 42; + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts === +export class IdentifierNameWithExtendedEscape2 { +>IdentifierNameWithExtendedEscape2 : Symbol(IdentifierNameWithExtendedEscape2, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 0)) + + x\u{78}: number; +>x : Symbol(IdentifierNameWithExtendedEscape2.x, Decl(IdentifierNameWithExtendedEscape2.ts, 0, 48)) +>u : Symbol(IdentifierNameWithExtendedEscape2.u, Decl(IdentifierNameWithExtendedEscape2.ts, 1, 6)) + + constructor() { + this.x\u{78} = 0; + } + + doThing() { + this.xx = 42; + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts === +export class PrivateIdentifierWithEscape1 { +>PrivateIdentifierWithEscape1 : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) + + #\u0078: number; +># : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) +>\u0078 : Symbol(PrivateIdentifierWithEscape1[\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 1, 5)) + + constructor() { + this.#\u0078 = 0; +>this.# : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) +>this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) + } + + doThing() { +>doThing : Symbol(PrivateIdentifierWithEscape1.doThing, Decl(PrivateIdentifierNameWithEscape1.ts, 5, 5)) + + this.#x = 42; +>this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts === +export class PrivateIdentifierWithEscape2 { +>PrivateIdentifierWithEscape2 : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) + + #x\u0078: number; +>#x\u0078 : Symbol(PrivateIdentifierWithEscape2.#x\u0078, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 43)) + + constructor() { + this.#x\u0078 = 0; +>this.#x\u0078 : Symbol(PrivateIdentifierWithEscape2.#x\u0078, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 43)) +>this : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) + } + + doThing() { +>doThing : Symbol(PrivateIdentifierWithEscape2.doThing, Decl(PrivateIdentifierNameWithEscape2.ts, 5, 5)) + + this.#xx = 42; +>this : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts === +export class PrivateIdentifierWithExtendedEscape1 { +>PrivateIdentifierWithExtendedEscape1 : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) + + #\u{78}: number; +># : Symbol(PrivateIdentifierWithExtendedEscape1[#], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) +>u : Symbol(PrivateIdentifierWithExtendedEscape1.u, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 1, 6)) + + constructor() { + this.#\u{78} = 0; + } + + doThing() { + this.#x = 42; + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts === +export class PrivateIdentifierWithExtendedEscape2 { +>PrivateIdentifierWithExtendedEscape2 : Symbol(PrivateIdentifierWithExtendedEscape2, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 0)) + + #x\u{78}: number; +>#x : Symbol(PrivateIdentifierWithExtendedEscape2.#x, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 51)) +>u : Symbol(PrivateIdentifierWithExtendedEscape2.u, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 1, 7)) + + constructor() { + this.#x\u{78} = 0; + } + + doThing() { + this.#xx = 42; + } +} + diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types new file mode 100644 index 0000000000000..db5218ae65847 --- /dev/null +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types @@ -0,0 +1,249 @@ +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts === +export class IdentifierNameWithEscape1 { +>IdentifierNameWithEscape1 : IdentifierNameWithEscape1 + + \u0078: number; +>\u0078 : number + + constructor() { + this.\u0078 = 0; +>this.\u0078 = 0 : 0 +>this.\u0078 : number +>this : this +>\u0078 : number +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.x = 42; +>this.x = 42 : 42 +>this.x : number +>this : this +>x : number +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts === +export class IdentifierNameWithEscape2 { +>IdentifierNameWithEscape2 : IdentifierNameWithEscape2 + + x\u0078: number; +>x\u0078 : number + + constructor() { + this.x\u0078 = 0; +>this.x\u0078 = 0 : 0 +>this.x\u0078 : number +>this : this +>x\u0078 : number +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.xx = 42; +>this.xx = 42 : 42 +>this.xx : number +>this : this +>xx : number +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts === +export class IdentifierNameWithExtendedEscape1 { +>IdentifierNameWithExtendedEscape1 : IdentifierNameWithExtendedEscape1 + + \u{78}: number; +>u : any +>78 : 78 +>number : any + + constructor() { +>constructor() : any +>constructor : any + + this.\u{78} = 0; +>this. : any +>this : undefined +> : any +>u : any +>78 : 78 +>0 : 0 + } + + doThing() { +>doThing() : any +>doThing : any + + this.x = 42; +>this.x = 42 : 42 +>this.x : any +>this : undefined +>x : any +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts === +export class IdentifierNameWithExtendedEscape2 { +>IdentifierNameWithExtendedEscape2 : IdentifierNameWithExtendedEscape2 + + x\u{78}: number; +>x : any +>u : any +>78 : 78 +>number : any + + constructor() { +>constructor() : any +>constructor : any + + this.x\u{78} = 0; +>this.x : any +>this : undefined +>x : any +>u : any +>78 : 78 +>0 : 0 + } + + doThing() { +>doThing() : any +>doThing : any + + this.xx = 42; +>this.xx = 42 : 42 +>this.xx : any +>this : undefined +>xx : any +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts === +export class PrivateIdentifierWithEscape1 { +>PrivateIdentifierWithEscape1 : PrivateIdentifierWithEscape1 + + #\u0078: number; +># : any +>\u0078 : number + + constructor() { + this.#\u0078 = 0; +>this.# : any +>this : this +>\u0078 = 0 : 0 +>\u0078 : any +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.#x = 42; +>this.#x = 42 : 42 +>this.#x : any +>this : this +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts === +export class PrivateIdentifierWithEscape2 { +>PrivateIdentifierWithEscape2 : PrivateIdentifierWithEscape2 + + #x\u0078: number; +>#x\u0078 : number + + constructor() { + this.#x\u0078 = 0; +>this.#x\u0078 = 0 : 0 +>this.#x\u0078 : number +>this : this +>0 : 0 + } + + doThing() { +>doThing : () => void + + this.#xx = 42; +>this.#xx = 42 : 42 +>this.#xx : any +>this : this +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts === +export class PrivateIdentifierWithExtendedEscape1 { +>PrivateIdentifierWithExtendedEscape1 : PrivateIdentifierWithExtendedEscape1 + + #\u{78}: number; +># : any +>u : any +>78 : 78 +>number : any + + constructor() { +>constructor() : any +>constructor : any + + this.#\u{78} = 0; +>this.# : any +>this : undefined +>u : any +>78 : 78 +>0 : 0 + } + + doThing() { +>doThing() : any +>doThing : any + + this.#x = 42; +>this.#x = 42 : 42 +>this.#x : any +>this : undefined +>42 : 42 + } +} + +=== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts === +export class PrivateIdentifierWithExtendedEscape2 { +>PrivateIdentifierWithExtendedEscape2 : PrivateIdentifierWithExtendedEscape2 + + #x\u{78}: number; +>#x : any +>u : any +>78 : 78 +>number : any + + constructor() { +>constructor() : any +>constructor : any + + this.#x\u{78} = 0; +>this.#x : any +>this : undefined +>u : any +>78 : 78 +>0 : 0 + } + + doThing() { +>doThing() : any +>doThing : any + + this.#xx = 42; +>this.#xx = 42 : 42 +>this.#xx : any +>this : undefined +>42 : 42 + } +} + From 69195a92a1c4c253d37236a85fdf3048e74078cc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 07:45:00 +0000 Subject: [PATCH 3/7] Store the tokenValue instead of tokenText on PrivateIdentifiers, since the latter can contain escapes and lead to semantic discrepancies. --- src/compiler/parser.ts | 2 +- src/compiler/scanner.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 85f13a159ca04..0f1add9b5e6e6 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2281,7 +2281,7 @@ namespace ts { function parsePrivateIdentifier(): PrivateIdentifier { const pos = getNodePos(); - const node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenText())); + const node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenValue())); nextToken(); return finishNode(node, pos); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a54389fbb9474..2de637d332723 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2054,6 +2054,11 @@ namespace ts { if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; + // We're relying on scanIdentifier's behavior and adjusting the token kind after the fact. + // Notably absent from this block is the fact that calling a function named "scanIdentifier", + // but identifiers don't include '#', and that function doesn't deal with it at all. + // This works because 'scanIdentifier' tries to reuse source characters and builds up substrings; + // however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us. scanIdentifier(codePointAt(text, pos), languageVersion); } else { From fec097795161cb4b38d9538548c3677d27f7e505 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 07:45:09 +0000 Subject: [PATCH 4/7] Accepted baselines. --- ...scapeSequences01(target=es2015).errors.txt | 10 ++-------- ...teNamesEscapeSequences01(target=es2015).js | 20 +++++++++---------- ...esEscapeSequences01(target=es2015).symbols | 2 ++ ...amesEscapeSequences01(target=es2015).types | 4 ++-- ...esEscapeSequences01(target=es5).errors.txt | 5 +---- ...ivateNamesEscapeSequences01(target=es5).js | 10 +++++----- ...NamesEscapeSequences01(target=es5).symbols | 1 + ...teNamesEscapeSequences01(target=es5).types | 2 +- 8 files changed, 24 insertions(+), 30 deletions(-) diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt index 1c21527bbff9e..9df8b4f86664e 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt @@ -4,14 +4,12 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEs tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS1005: ';' expected. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(9,14): error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,6): error TS1005: ';' expected. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,14): error TS1127: Invalid character. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS1005: ';' expected. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS2663: Cannot find name '\u{78}'. Did you mean the instance member 'this.\u{78}'? tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithExtendedEscape1'. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts(9,14): error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithExtendedEscape2'. ==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts (0 errors) ==== @@ -91,7 +89,7 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx } } -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (1 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (0 errors) ==== export class PrivateIdentifierWithEscape2 { #x\u0078: number; @@ -101,8 +99,6 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx doThing() { this.#xx = 42; - ~~~ -!!! error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. } } @@ -131,7 +127,7 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx } } -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts (1 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts (0 errors) ==== export class PrivateIdentifierWithExtendedEscape2 { #x\u{78}: number; @@ -141,8 +137,6 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx doThing() { this.#xx = 42; - ~~~ -!!! error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithExtendedEscape2'. } } \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js index 953ab7a7feb0e..113a56467111b 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js @@ -166,17 +166,17 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function ( if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var _PrivateIdentifierWithEscape2_x\u0078; +var _PrivateIdentifierWithEscape2_xx; export class PrivateIdentifierWithEscape2 { constructor() { - _PrivateIdentifierWithEscape2_x\u0078.set(this, void 0); - __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_x\u0078, 0, "f"); + _PrivateIdentifierWithEscape2_xx.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_xx, 0, "f"); } doThing() { - this. = 42; + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_xx, 42, "f"); } } -_PrivateIdentifierWithEscape2_x\u0078 = new WeakMap(); +_PrivateIdentifierWithEscape2_xx = new WeakMap(); //// [PrivateIdentifierNameWithExtendedEscape1.js] var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); @@ -202,14 +202,14 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function ( if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var _PrivateIdentifierWithExtendedEscape2_x\u{78}; +var _PrivateIdentifierWithExtendedEscape2_xx; export class PrivateIdentifierWithExtendedEscape2 { constructor() { - _PrivateIdentifierWithExtendedEscape2_x\u{78}.set(this, void 0); - __classPrivateFieldSet(this, _PrivateIdentifierWithExtendedEscape2_x\u{78}, 0, "f"); + _PrivateIdentifierWithExtendedEscape2_xx.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithExtendedEscape2_xx, 0, "f"); } doThing() { - this. = 42; + __classPrivateFieldSet(this, _PrivateIdentifierWithExtendedEscape2_xx, 42, "f"); } } -_PrivateIdentifierWithExtendedEscape2_x\u{78} = new WeakMap(); +_PrivateIdentifierWithExtendedEscape2_xx = new WeakMap(); diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols index f67c00ae4bec5..9475ad7fee4d9 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols @@ -133,6 +133,7 @@ export class PrivateIdentifierWithEscape2 { >doThing : Symbol(PrivateIdentifierWithEscape2.doThing, Decl(PrivateIdentifierNameWithEscape2.ts, 5, 5)) this.#xx = 42; +>this.#xx : Symbol(PrivateIdentifierWithEscape2.#x\u0078, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 43)) >this : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) } } @@ -176,6 +177,7 @@ export class PrivateIdentifierWithExtendedEscape2 { >doThing : Symbol(PrivateIdentifierWithExtendedEscape2.doThing, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 5, 5)) this.#xx = 42; +>this.#xx : Symbol(PrivateIdentifierWithExtendedEscape2.#x\u{78}, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 51)) >this : Symbol(PrivateIdentifierWithExtendedEscape2, Decl(PrivateIdentifierNameWithExtendedEscape2.ts, 0, 0)) } } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types index fdcdd3ac35e38..df2395f3ae1d1 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types @@ -158,7 +158,7 @@ export class PrivateIdentifierWithEscape2 { this.#xx = 42; >this.#xx = 42 : 42 ->this.#xx : any +>this.#xx : number >this : this >42 : 42 } @@ -212,7 +212,7 @@ export class PrivateIdentifierWithExtendedEscape2 { this.#xx = 42; >this.#xx = 42 : 42 ->this.#xx : any +>this.#xx : number >this : this >42 : 42 } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt index 2e261efb997f3..b0555ef668be6 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt @@ -37,7 +37,6 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEs tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(2,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(9,14): error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,6): error TS1127: Invalid character. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,7): error TS1434: Unexpected keyword or identifier. @@ -215,7 +214,7 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx } } -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (2 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (1 errors) ==== export class PrivateIdentifierWithEscape2 { #x\u0078: number; ~~~~~~~~ @@ -227,8 +226,6 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx doThing() { this.#xx = 42; - ~~~ -!!! error TS2339: Property '#xx' does not exist on type 'PrivateIdentifierWithEscape2'. } } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js index 6c631bd49dd4a..0f2d66a65da8d 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js @@ -218,21 +218,21 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function ( if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var _PrivateIdentifierWithEscape2_x\u0078; +var _PrivateIdentifierWithEscape2_xx; Object.defineProperty(exports, "__esModule", { value: true }); exports.PrivateIdentifierWithEscape2 = void 0; var PrivateIdentifierWithEscape2 = /** @class */ (function () { function PrivateIdentifierWithEscape2() { - _PrivateIdentifierWithEscape2_x\u0078.set(this, void 0); - __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_x\u0078, 0, "f"); + _PrivateIdentifierWithEscape2_xx.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_xx, 0, "f"); } PrivateIdentifierWithEscape2.prototype.doThing = function () { - this. = 42; + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape2_xx, 42, "f"); }; return PrivateIdentifierWithEscape2; }()); exports.PrivateIdentifierWithEscape2 = PrivateIdentifierWithEscape2; -_PrivateIdentifierWithEscape2_x\u0078 = new WeakMap(); +_PrivateIdentifierWithEscape2_xx = new WeakMap(); //// [PrivateIdentifierNameWithExtendedEscape1.js] "use strict"; var _PrivateIdentifierWithExtendedEscape1_; diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols index 0f1c15f985353..6b36ba1cf0c14 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols @@ -118,6 +118,7 @@ export class PrivateIdentifierWithEscape2 { >doThing : Symbol(PrivateIdentifierWithEscape2.doThing, Decl(PrivateIdentifierNameWithEscape2.ts, 5, 5)) this.#xx = 42; +>this.#xx : Symbol(PrivateIdentifierWithEscape2.#x\u0078, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 43)) >this : Symbol(PrivateIdentifierWithEscape2, Decl(PrivateIdentifierNameWithEscape2.ts, 0, 0)) } } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types index db5218ae65847..77c3d480f65a2 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types @@ -173,7 +173,7 @@ export class PrivateIdentifierWithEscape2 { this.#xx = 42; >this.#xx = 42 : 42 ->this.#xx : any +>this.#xx : number >this : this >42 : 42 } From 6fccba57895550a26a11847e028233fe98ae4c5b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 08:04:17 +0000 Subject: [PATCH 5/7] Check for leading escape sequences in PrivateIdentifiers. --- src/compiler/scanner.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 2de637d332723..539c53bb600bd 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2052,17 +2052,38 @@ namespace ts { return token = SyntaxKind.Unknown; } - if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { + const charAfterHash = codePointAt(text, pos + 1); + if (charAfterHash === CharacterCodes.backslash) { + pos++ + const extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= TokenFlags.ExtendedUnicodeEscape; + tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = SyntaxKind.PrivateIdentifier; + } + + const cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= TokenFlags.UnicodeEscape; + tokenValue = "#" + String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = SyntaxKind.PrivateIdentifier; + } + pos--; + } + + if (isIdentifierStart(charAfterHash, languageVersion)) { pos++; // We're relying on scanIdentifier's behavior and adjusting the token kind after the fact. // Notably absent from this block is the fact that calling a function named "scanIdentifier", // but identifiers don't include '#', and that function doesn't deal with it at all. // This works because 'scanIdentifier' tries to reuse source characters and builds up substrings; // however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us. - scanIdentifier(codePointAt(text, pos), languageVersion); + scanIdentifier(charAfterHash, languageVersion); } else { - tokenValue = String.fromCharCode(codePointAt(text, pos)); + tokenValue = "#"; error(Diagnostics.Invalid_character, pos++, charSize(ch)); } return token = SyntaxKind.PrivateIdentifier; From 83b3ea37f1ca1646b0e6ef941237259851e959f8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 08:04:26 +0000 Subject: [PATCH 6/7] Accepted baselines. --- ...scapeSequences01(target=es2015).errors.txt | 142 ------------------ ...teNamesEscapeSequences01(target=es2015).js | 40 ++--- ...esEscapeSequences01(target=es2015).symbols | 12 +- ...amesEscapeSequences01(target=es2015).types | 20 +-- ...esEscapeSequences01(target=es5).errors.txt | 23 +-- ...ivateNamesEscapeSequences01(target=es5).js | 20 +-- ...NamesEscapeSequences01(target=es5).symbols | 6 +- ...teNamesEscapeSequences01(target=es5).types | 10 +- 8 files changed, 55 insertions(+), 218 deletions(-) delete mode 100644 tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt deleted file mode 100644 index 9df8b4f86664e..0000000000000 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).errors.txt +++ /dev/null @@ -1,142 +0,0 @@ -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,5): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,6): error TS1005: ';' expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,14): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS1005: ';' expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,6): error TS1005: ';' expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,14): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS1005: ';' expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(5,15): error TS2663: Cannot find name '\u{78}'. Did you mean the instance member 'this.\u{78}'? -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithExtendedEscape1'. - - -==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape1.ts (0 errors) ==== - export class IdentifierNameWithEscape1 { - \u0078: number; - - constructor() { - this.\u0078 = 0; - } - - doThing() { - this.x = 42; - } - } - -==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithEscape2.ts (0 errors) ==== - export class IdentifierNameWithEscape2 { - x\u0078: number; - - constructor() { - this.x\u0078 = 0; - } - - doThing() { - this.xx = 42; - } - } - -==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape1.ts (0 errors) ==== - export class IdentifierNameWithExtendedEscape1 { - \u{78}: number; - - constructor() { - this.\u{78} = 0; - } - - doThing() { - this.x = 42; - } - } - -==== tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts (0 errors) ==== - export class IdentifierNameWithExtendedEscape2 { - x\u{78}: number; - - constructor() { - this.x\u{78} = 0; - } - - doThing() { - this.xx = 42; - } - } - -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts (6 errors) ==== - export class PrivateIdentifierWithEscape1 { - #\u0078: number; - ~ -!!! error TS1127: Invalid character. - ~~~~~~ -!!! error TS1005: ';' expected. - - constructor() { - this.#\u0078 = 0; - ~ -!!! error TS1127: Invalid character. - ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ -!!! error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? - } - - doThing() { - this.#x = 42; - ~~ -!!! error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. - } - } - -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts (0 errors) ==== - export class PrivateIdentifierWithEscape2 { - #x\u0078: number; - - constructor() { - this.#x\u0078 = 0; - } - - doThing() { - this.#xx = 42; - } - } - -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts (6 errors) ==== - export class PrivateIdentifierWithExtendedEscape1 { - #\u{78}: number; - ~ -!!! error TS1127: Invalid character. - ~~~~~~ -!!! error TS1005: ';' expected. - - constructor() { - this.#\u{78} = 0; - ~ -!!! error TS1127: Invalid character. - ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ -!!! error TS2663: Cannot find name '\u{78}'. Did you mean the instance member 'this.\u{78}'? - } - - doThing() { - this.#x = 42; - ~~ -!!! error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithExtendedEscape1'. - } - } - -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape2.ts (0 errors) ==== - export class PrivateIdentifierWithExtendedEscape2 { - #x\u{78}: number; - - constructor() { - this.#x\u{78} = 0; - } - - doThing() { - this.#xx = 42; - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js index 113a56467111b..7884e774e63d4 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).js @@ -142,23 +142,23 @@ export class IdentifierNameWithExtendedEscape2 { } } //// [PrivateIdentifierNameWithEscape1.js] -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var _PrivateIdentifierWithEscape1_; +var _PrivateIdentifierWithEscape1_x; export class PrivateIdentifierWithEscape1 { constructor() { - _PrivateIdentifierWithEscape1_.set(this, void 0); - __classPrivateFieldGet(this, _PrivateIdentifierWithEscape1_, "f"); - \u0078 = 0; + _PrivateIdentifierWithEscape1_x.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape1_x, 0, "f"); } doThing() { - this. = 42; + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape1_x, 42, "f"); } } -_PrivateIdentifierWithEscape1_ = new WeakMap(); +_PrivateIdentifierWithEscape1_x = new WeakMap(); //// [PrivateIdentifierNameWithEscape2.js] var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); @@ -178,23 +178,23 @@ export class PrivateIdentifierWithEscape2 { } _PrivateIdentifierWithEscape2_xx = new WeakMap(); //// [PrivateIdentifierNameWithExtendedEscape1.js] -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var _PrivateIdentifierWithExtendedEscape1_; +var _PrivateIdentifierWithExtendedEscape1_x; export class PrivateIdentifierWithExtendedEscape1 { constructor() { - _PrivateIdentifierWithExtendedEscape1_.set(this, void 0); - __classPrivateFieldGet(this, _PrivateIdentifierWithExtendedEscape1_, "f"); - \u{78} = 0; + _PrivateIdentifierWithExtendedEscape1_x.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithExtendedEscape1_x, 0, "f"); } doThing() { - this. = 42; + __classPrivateFieldSet(this, _PrivateIdentifierWithExtendedEscape1_x, 42, "f"); } } -_PrivateIdentifierWithExtendedEscape1_ = new WeakMap(); +_PrivateIdentifierWithExtendedEscape1_x = new WeakMap(); //// [PrivateIdentifierNameWithExtendedEscape2.js] var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols index 9475ad7fee4d9..f13f8831abc27 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).symbols @@ -99,12 +99,11 @@ export class PrivateIdentifierWithEscape1 { >PrivateIdentifierWithEscape1 : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) #\u0078: number; -># : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) ->\u0078 : Symbol(PrivateIdentifierWithEscape1[\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 1, 5)) +>#\u0078 : Symbol(PrivateIdentifierWithEscape1[#\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) constructor() { this.#\u0078 = 0; ->this.# : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) +>this.#\u0078 : Symbol(PrivateIdentifierWithEscape1[#\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) >this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) } @@ -112,6 +111,7 @@ export class PrivateIdentifierWithEscape1 { >doThing : Symbol(PrivateIdentifierWithEscape1.doThing, Decl(PrivateIdentifierNameWithEscape1.ts, 5, 5)) this.#x = 42; +>this.#x : Symbol(PrivateIdentifierWithEscape1[#\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) >this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) } } @@ -143,12 +143,11 @@ export class PrivateIdentifierWithExtendedEscape1 { >PrivateIdentifierWithExtendedEscape1 : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) #\u{78}: number; -># : Symbol(PrivateIdentifierWithExtendedEscape1[#], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) ->\u{78} : Symbol(PrivateIdentifierWithExtendedEscape1[\u{78}], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 1, 5)) +>#\u{78} : Symbol(PrivateIdentifierWithExtendedEscape1[#\u{78}], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) constructor() { this.#\u{78} = 0; ->this.# : Symbol(PrivateIdentifierWithExtendedEscape1[#], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) +>this.#\u{78} : Symbol(PrivateIdentifierWithExtendedEscape1[#\u{78}], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) >this : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) } @@ -156,6 +155,7 @@ export class PrivateIdentifierWithExtendedEscape1 { >doThing : Symbol(PrivateIdentifierWithExtendedEscape1.doThing, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 5, 5)) this.#x = 42; +>this.#x : Symbol(PrivateIdentifierWithExtendedEscape1[#\u{78}], Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 51)) >this : Symbol(PrivateIdentifierWithExtendedEscape1, Decl(PrivateIdentifierNameWithExtendedEscape1.ts, 0, 0)) } } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types index df2395f3ae1d1..ca0ef82588993 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es2015).types @@ -115,15 +115,13 @@ export class PrivateIdentifierWithEscape1 { >PrivateIdentifierWithEscape1 : PrivateIdentifierWithEscape1 #\u0078: number; -># : any ->\u0078 : number +>#\u0078 : number constructor() { this.#\u0078 = 0; ->this.# : any +>this.#\u0078 = 0 : 0 +>this.#\u0078 : number >this : this ->\u0078 = 0 : 0 ->\u0078 : any >0 : 0 } @@ -132,7 +130,7 @@ export class PrivateIdentifierWithEscape1 { this.#x = 42; >this.#x = 42 : 42 ->this.#x : any +>this.#x : number >this : this >42 : 42 } @@ -169,15 +167,13 @@ export class PrivateIdentifierWithExtendedEscape1 { >PrivateIdentifierWithExtendedEscape1 : PrivateIdentifierWithExtendedEscape1 #\u{78}: number; -># : any ->\u{78} : number +>#\u{78} : number constructor() { this.#\u{78} = 0; ->this.# : any +>this.#\u{78} = 0 : 0 +>this.#\u{78} : number >this : this ->\u{78} = 0 : 0 ->\u{78} : any >0 : 0 } @@ -186,7 +182,7 @@ export class PrivateIdentifierWithExtendedEscape1 { this.#x = 42; >this.#x = 42 : 42 ->this.#x : any +>this.#x : number >this : this >42 : 42 } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt index b0555ef668be6..a042d459e8a30 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).errors.txt @@ -30,12 +30,7 @@ tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedE tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(8,15): error TS1005: ';' expected. tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(9,9): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/classes/members/privateNames/IdentifierNameWithExtendedEscape2.ts(11,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,5): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,6): error TS1005: ';' expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,14): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS1005: ';' expected. -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(5,15): error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? -tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(9,14): error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. +tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts(2,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape2.ts(2,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,5): error TS1127: Invalid character. tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithExtendedEscape1.ts(2,6): error TS1127: Invalid character. @@ -189,28 +184,18 @@ tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEx ~ !!! error TS1128: Declaration or statement expected. -==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts (6 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/PrivateIdentifierNameWithEscape1.ts (1 errors) ==== export class PrivateIdentifierWithEscape1 { #\u0078: number; - ~ -!!! error TS1127: Invalid character. - ~~~~~~ -!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. constructor() { this.#\u0078 = 0; - ~ -!!! error TS1127: Invalid character. - ~~~~~~ -!!! error TS1005: ';' expected. - ~~~~~~ -!!! error TS2663: Cannot find name '\u0078'. Did you mean the instance member 'this.\u0078'? } doThing() { this.#x = 42; - ~~ -!!! error TS2339: Property '#x' does not exist on type 'PrivateIdentifierWithEscape1'. } } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js index 0f2d66a65da8d..fc9d1eb7771c2 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).js @@ -189,27 +189,27 @@ doThing(); } //// [PrivateIdentifierNameWithEscape1.js] "use strict"; -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var _PrivateIdentifierWithEscape1_; +var _PrivateIdentifierWithEscape1_x; Object.defineProperty(exports, "__esModule", { value: true }); exports.PrivateIdentifierWithEscape1 = void 0; var PrivateIdentifierWithEscape1 = /** @class */ (function () { function PrivateIdentifierWithEscape1() { - _PrivateIdentifierWithEscape1_.set(this, void 0); - __classPrivateFieldGet(this, _PrivateIdentifierWithEscape1_, "f"); - \u0078 = 0; + _PrivateIdentifierWithEscape1_x.set(this, void 0); + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape1_x, 0, "f"); } PrivateIdentifierWithEscape1.prototype.doThing = function () { - this. = 42; + __classPrivateFieldSet(this, _PrivateIdentifierWithEscape1_x, 42, "f"); }; return PrivateIdentifierWithEscape1; }()); exports.PrivateIdentifierWithEscape1 = PrivateIdentifierWithEscape1; -_PrivateIdentifierWithEscape1_ = new WeakMap(); +_PrivateIdentifierWithEscape1_x = new WeakMap(); //// [PrivateIdentifierNameWithEscape2.js] "use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols index 6b36ba1cf0c14..a950d1860864a 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).symbols @@ -84,12 +84,11 @@ export class PrivateIdentifierWithEscape1 { >PrivateIdentifierWithEscape1 : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) #\u0078: number; -># : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) ->\u0078 : Symbol(PrivateIdentifierWithEscape1[\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 1, 5)) +>#\u0078 : Symbol(PrivateIdentifierWithEscape1[#\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) constructor() { this.#\u0078 = 0; ->this.# : Symbol(PrivateIdentifierWithEscape1[#], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) +>this.#\u0078 : Symbol(PrivateIdentifierWithEscape1[#\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) >this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) } @@ -97,6 +96,7 @@ export class PrivateIdentifierWithEscape1 { >doThing : Symbol(PrivateIdentifierWithEscape1.doThing, Decl(PrivateIdentifierNameWithEscape1.ts, 5, 5)) this.#x = 42; +>this.#x : Symbol(PrivateIdentifierWithEscape1[#\u0078], Decl(PrivateIdentifierNameWithEscape1.ts, 0, 43)) >this : Symbol(PrivateIdentifierWithEscape1, Decl(PrivateIdentifierNameWithEscape1.ts, 0, 0)) } } diff --git a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types index 77c3d480f65a2..e9ae9d761f647 100644 --- a/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types +++ b/tests/baselines/reference/privateNamesEscapeSequences01(target=es5).types @@ -130,15 +130,13 @@ export class PrivateIdentifierWithEscape1 { >PrivateIdentifierWithEscape1 : PrivateIdentifierWithEscape1 #\u0078: number; -># : any ->\u0078 : number +>#\u0078 : number constructor() { this.#\u0078 = 0; ->this.# : any +>this.#\u0078 = 0 : 0 +>this.#\u0078 : number >this : this ->\u0078 = 0 : 0 ->\u0078 : any >0 : 0 } @@ -147,7 +145,7 @@ export class PrivateIdentifierWithEscape1 { this.#x = 42; >this.#x = 42 : 42 ->this.#x : any +>this.#x : number >this : this >42 : 42 } From 82d0fc98ab1a857a532e8497becd014213c4274e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 20 Sep 2022 08:19:16 +0000 Subject: [PATCH 7/7] Fix lints. --- src/compiler/scanner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 539c53bb600bd..b5840ec6ab1c1 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2054,7 +2054,7 @@ namespace ts { const charAfterHash = codePointAt(text, pos + 1); if (charAfterHash === CharacterCodes.backslash) { - pos++ + pos++; const extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; @@ -2062,7 +2062,7 @@ namespace ts { tokenValue = "#" + scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = SyntaxKind.PrivateIdentifier; } - + const cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6;