-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use 'new' error on intersection type with constructor #17388
Comments
This regressed between 2.1 and 2.2 |
Adding this from StackOverflow for completeness I have identified a problem when using intersection types in TypeScript... I have three type aliases:
I have tried these intersection permutations:
Example
Try it in the Playground Error
Why does the TypeScript compiler recognise the |
I may be running into this as well. Here's my example:
|
This is correct. |
intersection also contains non-constructor types. Fixes microsoft#17388.
A silly mistake in the logic for handling mixin classes. Fix is in #27701. |
intersection also contains non-constructor types. Fixes microsoft#17388.
tsc: 2.4.2
http://www.typescriptlang.org/play/index.html#src=class%20X%20%7B%20%7D%0D%0Adeclare%20interface%20ConstructorAnyArgs%3CTClass%3E%20%7B%0D%0A%20%20%20%20new%20(...args%3A%20any%5B%5D)%3A%20TClass%0D%0A%7D%0D%0A%0D%0A%0D%0Afunction%20foo()%3A%20ConstructorAnyArgs%3CX%3E%20%7B%20return%20%7D%0D%0Afunction%20boo()%3A%20ConstructorAnyArgs%3CX%3E%20%26%20%7B%20superclass%3A%20any%20%7D%20%7B%20return%20%7D%0D%0A%0D%0Alet%20Y%20%3D%20foo()%0D%0Alet%20y%20%3D%20new%20Y()%0D%0A%0D%0Alet%20Z%20%3D%20boo()%0D%0Alet%20z%20%3D%20new%20Z()%20%2F%2F%20Cannot%20use%20'new'%20with%20an%20expression%20whose%20type%20lacks%20a%20call%20or%20construct%20signature.%0D%0A
The text was updated successfully, but these errors were encountered: