swc/crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldDestructuredBinding.ts
2022-02-04 17:08:38 +09:00

27 lines
678 B
TypeScript

// @target: esnext, es2022, es2015
// @useDefineForClassFields: false
class A {
static #field = 1;
otherClass = A;
testObject() {
return { x: 10, y: 6 };
}
testArray() {
return [10, 11];
}
constructor() {
let y: number;
({ x: A.#field, y } = this.testObject());
([A.#field, y] = this.testArray());
({ a: A.#field, b: [A.#field] } = { a: 1, b: [2] });
[A.#field, [A.#field]] = [1, [2]];
({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] });
[A.#field = 2] = [];
[this.otherClass.#field = 2] = [];
}
static test(_a: typeof A) {
[_a.#field] = [2];
}
}