2023-02-23 10:55:58 +03:00
|
|
|
|
class A<T> {
|
2021-01-15 13:30:44 +03:00
|
|
|
|
genericVar: T
|
|
|
|
|
}
|
|
|
|
|
function B1<U>() {
|
|
|
|
|
// class expression can use T
|
|
|
|
|
return class extends A<U> { }
|
|
|
|
|
}
|
|
|
|
|
class B2<V> {
|
|
|
|
|
anon = class extends A<V> { }
|
|
|
|
|
}
|
|
|
|
|
function B3<W>() {
|
|
|
|
|
return class Inner<TInner> extends A<W> { }
|
|
|
|
|
}
|
|
|
|
|
// extends can call B
|
|
|
|
|
class K extends B1<number>() {
|
|
|
|
|
namae: string;
|
|
|
|
|
}
|
|
|
|
|
class C extends (new B2<number>().anon) {
|
|
|
|
|
name: string;
|
|
|
|
|
}
|
|
|
|
|
let b3Number = B3<number>();
|
|
|
|
|
class S extends b3Number<string> {
|
|
|
|
|
nom: string;
|
|
|
|
|
}
|
|
|
|
|
var c = new C();
|
|
|
|
|
var k = new K();
|
|
|
|
|
var s = new S();
|
|
|
|
|
c.genericVar = 12;
|
|
|
|
|
k.genericVar = 12;
|
|
|
|
|
s.genericVar = 12;
|