swc/crates/swc_ecma_parser/tests/tsc/privateNamesAndGenericClasses-2.ts

30 lines
572 B
TypeScript
Raw Normal View History

// @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