mirror of
https://github.com/swc-project/swc.git
synced 2024-12-19 03:31:45 +03:00
42 lines
697 B
TypeScript
42 lines
697 B
TypeScript
class C<T extends number> {
|
|
x: T;
|
|
get X(): T { return null; }
|
|
foo(): T {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
class D extends C<number> {
|
|
x: any;
|
|
get X(): any {
|
|
return null;
|
|
}
|
|
foo(): any {
|
|
return 1;
|
|
}
|
|
|
|
static y: any;
|
|
static get Y(): any {
|
|
return null;
|
|
}
|
|
static bar(): any {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// if D is a valid class definition than E is now not safe tranisitively through C
|
|
class E<T extends string> extends D {
|
|
x: T;
|
|
get X(): T { return ''; } // error
|
|
foo(): T {
|
|
return ''; // error
|
|
}
|
|
}
|
|
|
|
var c: C<number>;
|
|
var d: D;
|
|
var e: E<string>;
|
|
|
|
c = d;
|
|
c = e;
|
|
var r = c.foo(); // e.foo would return string
|