-
Notifications
You must be signed in to change notification settings - Fork 12.8k
chained generic mixins fail #28594
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
Comments
I think this is the same as #13807. |
I believe that's because _T1 is just a constructor. When you pass a generic type to another generic function, it appears to lose the ability to tell that it is a constructor function type. The error your getting is not from the arg you are passing to make, it's actually from trying to extend the result of your make function call. I believe my examples below illustrate the problem more clearly.
Both make2's anonymous class and Test1 class are able to extend
Both make4's anonymous class and Test2 class are able to extend Based on the above two examples, we can see that both Constructor and T are constructor type functions and it allows them to be used as such. So how about the union of T & Constructor?
The Test3 class is able to extend
Based on the fact that it works for the Test3 class but not make6's anonymous class, it looks like it doesn't recognize that T is extending Constructor. I believe that is why it refuses to accept T & Constructor as a constructor function type. After seeing that I decided to try without casting.
Just like the other example, the Test4 class is able to extend
I suspect the reason is the same, T not being recognized as being a constructor function type. I tried finding ways to work around this issue but haven't been able to. Both of the workarounds shown above, casting to T or Constructor, work but have drawbacks.
|
TypeScript Version: 3.2.0-dev.201xxxxx
Search Terms: chained generic mixins
Code
Expected behavior:
Compile.
Actual behavior:
Type '{ new (...args: any[]): make.(Anonymous class); prototype: make.(Anonymous class); } & T' is not a constructor function type.
The text was updated successfully, but these errors were encountered: