TypeScript/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.types
2014-08-28 12:31:37 -07:00

65 lines
1.1 KiB
Plaintext

=== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/constructorFunctionTypeIsAssignableToBaseType2.ts ===
// the constructor function itself does not need to be a subtype of the base type constructor function
class Base {
>Base : Base
static foo: {
>foo : { bar: Object; }
bar: Object;
>bar : Object
>Object : Object
}
constructor(x: Object) {
>x : Object
>Object : Object
}
}
class Derived extends Base {
>Derived : Derived
>Base : Base
// ok
static foo: {
>foo : { bar: number; }
bar: number;
>bar : number
}
constructor(x: number) {
>x : number
super(x);
>super(x) : void
>super : typeof Base
>x : number
}
}
class Derived2 extends Base {
>Derived2 : Derived2
>Base : Base
static foo: {
>foo : { bar: number; }
bar: number;
>bar : number
}
// ok, not enforcing assignability relation on this
constructor(x: any) {
>x : any
super(x);
>super(x) : void
>super : typeof Base
>x : any
return 1;
}
}