-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 auto parse right type in these code #13844
Comments
I tried to fix this with #6118 but it breaks existing code. I gave the reason in this comment. |
Duplicate of #3667, except for statics. |
Not Duplicate of #3667 |
Sorry, I missed the second line of the "actual" description where you talked about removing GetEventHandler. |
This is actually the same issue caused by #10978. The compiler is building a new type
|
well let's consider what will happen when we rename D.GetEventHandlers to D.a like now we want to know type of D.a it seems like it will meet the same problem, but IT"S NOT why? i guess, when we try to compare Hash to { b: (s:D)=> void } but, consider this: what's type of D? extends BaseEventDealer, is it extends correctly? depends on type of D.GetEventHandler, so we check D.GetEventHandler I mean, here we got an error of recursive type parsing, but after we temporary consider it as any, everything will go just fine.Will it be a solution? |
consider the same problem in #10978. `class M { const a = new M(() => a); /` as RyanCavanaugh commented: then we don't know type of a, then we temporary treat is as any, |
things can have only one type. having a type |
maybe I should not call it any, we can call it unsolved(which treat as any) |
It does not matter what you call it. What matters is the same expression has different types at different places. |
I try to explain it in another way when we meet a symbol which type is unable to parse but we know what it should be. |
this is not how the typescript compiler works. |
TypeScript Version: 2.1.4
Code
Expected behavior:
type of D.h should be Hash<EventHandler>
type of return value of D.GetEventHandler should be EventHandler
Actual behavior:
type of D.h and return value of D.GetEventHandler both is ImplicitAny
but if you remove D.GetEventHandler or change its name, h will get right type
or you manually declare h:Hash<EventHandler> or GetEventHandler(event: string):EventHandler, they will both get right type
The text was updated successfully, but these errors were encountered: