2016-12-23 22:31:38 +03:00
|
|
|
class C {
|
|
|
|
constructor() { }
|
|
|
|
}
|
|
|
|
|
|
|
|
class D {
|
|
|
|
constructor():number { }
|
|
|
|
}
|
|
|
|
|
2017-04-08 17:52:38 +03:00
|
|
|
// the return type of a constructor overrides the type of the class
|
|
|
|
declare class Bar<T> {}
|
|
|
|
declare class Foo<T> {
|
|
|
|
constructor<U>(iterable: U): Bar<U>;
|
|
|
|
}
|
|
|
|
(new Foo('x'): Bar<string>); // ok
|
|
|
|
(new Foo(123): Bar<string>); // error, number !~> string
|
|
|
|
|
|
|
|
// also overrides when it returns a different specialization of the same class
|
|
|
|
declare class Baz<T> {
|
|
|
|
constructor<U>(iterable: U): Baz<U>;
|
|
|
|
}
|
|
|
|
(new Baz('x'): Baz<string>); // ok
|
|
|
|
(new Baz(123): Baz<string>); // error, number !~> string
|