Closed
Description
TypeScript Version: 2.7.2
Search Terms: Function interface, object literal type, intersection, type alias
Code
type MyConstructorType = Function & {prototype: {foo: number}};
let bar = (function () { }) as MyConstructorType;
bar.prototype.foo();
or equivalent:
let bar = (function () { }) as Function & {prototype: {foo: number}};
bar.prototype.foo();
doesn't even depend on the order
let bar = (function () { }) as {prototype: {foo: number}} & Function;
bar.prototype.foo();
Expected behavior:
The function call bar.prototype.foo()
should throw a compile time error, as foo
is marked as a number.
Actual behavior:
The property bar.prototype
is of type any
, no matter the intersection type.
Playground Link: here
Related Issues: #17757