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

39 lines
755 B
TypeScript

// @target: esnext, es2022, es2015
class A {
#a = 'a';
#b: string;
readonly #c = 'c';
readonly #d: string;
#e = '';
constructor() {
this.#b = 'b';
this.#d = 'd';
}
test() {
const data: Record<string, string> = { a: 'a', b: 'b', c: 'c', d: 'd', e: 'e' };
const {
[this.#a]: a,
[this.#b]: b,
[this.#c]: c,
[this.#d]: d,
[this.#e = 'e']: e,
} = data;
console.log(a, b, c, d, e);
const a1 = data[this.#a];
const b1 = data[this.#b];
const c1 = data[this.#c];
const d1 = data[this.#d];
const e1 = data[this.#e];
console.log(a1, b1, c1, d1);
}
}
new A().test();