mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add second test case
This commit is contained in:
+29
-1
@@ -13,6 +13,20 @@ class A {
|
||||
console.log(this.exposedField);
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
readonly #privateField: string;
|
||||
|
||||
constructor(arg: { key: string }, public exposedField: number) {
|
||||
"prologue";
|
||||
({ key: this.#privateField } = arg);
|
||||
}
|
||||
|
||||
log() {
|
||||
console.log(this.#privateField);
|
||||
console.log(this.exposedField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [constructorWithParameterPropertiesAndPrivateFields.es2015.js]
|
||||
@@ -28,7 +42,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
||||
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 _A_privateField;
|
||||
var _A_privateField, _B_privateField;
|
||||
class A {
|
||||
constructor(arg, exposedField) {
|
||||
this.exposedField = exposedField;
|
||||
@@ -42,3 +56,17 @@ class A {
|
||||
}
|
||||
}
|
||||
_A_privateField = new WeakMap();
|
||||
class B {
|
||||
constructor(arg, exposedField) {
|
||||
this.exposedField = exposedField;
|
||||
"prologue";
|
||||
var _a;
|
||||
_B_privateField.set(this, void 0);
|
||||
(_a = this, { key: ({ set value(_b) { __classPrivateFieldSet(_a, _B_privateField, _b, "f"); } }).value } = arg);
|
||||
}
|
||||
log() {
|
||||
console.log(__classPrivateFieldGet(this, _B_privateField, "f"));
|
||||
console.log(this.exposedField);
|
||||
}
|
||||
}
|
||||
_B_privateField = new WeakMap();
|
||||
|
||||
+39
@@ -39,3 +39,42 @@ class A {
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
>B : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1))
|
||||
|
||||
readonly #privateField: string;
|
||||
>#privateField : Symbol(B.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 15, 9))
|
||||
|
||||
constructor(arg: { key: string }, public exposedField: number) {
|
||||
>arg : Symbol(arg, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 14))
|
||||
>key : Symbol(key, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 20))
|
||||
>exposedField : Symbol(B.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 35))
|
||||
|
||||
"prologue";
|
||||
({ key: this.#privateField } = arg);
|
||||
>key : Symbol(key, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 20, 6))
|
||||
>this.#privateField : Symbol(B.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 15, 9))
|
||||
>this : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1))
|
||||
>arg : Symbol(arg, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 14))
|
||||
}
|
||||
|
||||
log() {
|
||||
>log : Symbol(B.log, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 21, 3))
|
||||
|
||||
console.log(this.#privateField);
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>this.#privateField : Symbol(B.#privateField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 15, 9))
|
||||
>this : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1))
|
||||
|
||||
console.log(this.exposedField);
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>this.exposedField : Symbol(B.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 35))
|
||||
>this : Symbol(B, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 13, 1))
|
||||
>exposedField : Symbol(B.exposedField, Decl(constructorWithParameterPropertiesAndPrivateFields.es2015.ts, 18, 35))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+46
@@ -44,3 +44,49 @@ class A {
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
readonly #privateField: string;
|
||||
>#privateField : string
|
||||
|
||||
constructor(arg: { key: string }, public exposedField: number) {
|
||||
>arg : { key: string; }
|
||||
>key : string
|
||||
>exposedField : number
|
||||
|
||||
"prologue";
|
||||
>"prologue" : "prologue"
|
||||
|
||||
({ key: this.#privateField } = arg);
|
||||
>({ key: this.#privateField } = arg) : { key: string; }
|
||||
>{ key: this.#privateField } = arg : { key: string; }
|
||||
>{ key: this.#privateField } : { key: string; }
|
||||
>key : string
|
||||
>this.#privateField : string
|
||||
>this : this
|
||||
>arg : { key: string; }
|
||||
}
|
||||
|
||||
log() {
|
||||
>log : () => void
|
||||
|
||||
console.log(this.#privateField);
|
||||
>console.log(this.#privateField) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>this.#privateField : string
|
||||
>this : this
|
||||
|
||||
console.log(this.exposedField);
|
||||
>console.log(this.exposedField) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>this.exposedField : number
|
||||
>this : this
|
||||
>exposedField : number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,3 +13,17 @@ class A {
|
||||
console.log(this.exposedField);
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
readonly #privateField: string;
|
||||
|
||||
constructor(arg: { key: string }, public exposedField: number) {
|
||||
"prologue";
|
||||
({ key: this.#privateField } = arg);
|
||||
}
|
||||
|
||||
log() {
|
||||
console.log(this.#privateField);
|
||||
console.log(this.exposedField);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user