2014-08-15 23:33:16 +02:00
|
|
|
=== 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
|
2014-08-28 21:31:37 +02:00
|
|
|
>super : typeof Base
|
2014-08-15 23:33:16 +02:00
|
|
|
>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
|
2014-08-28 21:31:37 +02:00
|
|
|
>super : typeof Base
|
2014-08-15 23:33:16 +02:00
|
|
|
>x : any
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|