swc/crates/swc_ecma_parser/tests/tsc/derivedGenericClassWithAny.ts

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