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

35 lines
785 B
TypeScript

// @target: es2015
class Test {
set #value(v: { foo: { bar: number } }) {}
set #valueRest(v: number[]) {}
set #valueOne(v: number) {}
set #valueCompound(v: number) {}
m() {
const foo = { bar: 1 };
console.log(this.#value); // error
this.#value = { foo }; // ok
this.#value = { foo }; // ok
this.#value.foo = foo; // error
({ o: this.#value } = { o: { foo } }); //ok
({ ...this.#value } = { foo }); //ok
({ foo: this.#value.foo } = { foo }); //error
({
foo: { ...this.#value.foo },
} = { foo }); //error
let r = { o: this.#value }; //error
[this.#valueOne, ...this.#valueRest] = [1, 2, 3];
let arr = [
this.#valueOne,
...this.#valueRest
];
this.#valueCompound += 3;
}
}
new Test().m();