mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
30 lines
572 B
TypeScript
30 lines
572 B
TypeScript
|
// @strict: true
|
||
|
// @target: es6
|
||
|
|
||
|
class C<T> {
|
||
|
#foo: T;
|
||
|
#bar(): T {
|
||
|
return this.#foo;
|
||
|
}
|
||
|
constructor(t: T) {
|
||
|
this.#foo = t;
|
||
|
t = this.#bar();
|
||
|
}
|
||
|
set baz(t: T) {
|
||
|
this.#foo = t;
|
||
|
|
||
|
}
|
||
|
get baz(): T {
|
||
|
return this.#foo;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let a = new C(3);
|
||
|
let b = new C("hello");
|
||
|
|
||
|
a.baz = 5 // OK
|
||
|
const x: number = a.baz // OK
|
||
|
a.#foo; // Error
|
||
|
a = b; // Error
|
||
|
b = a; // Error
|