-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Explicit generic type argument gets lost when attempting to carry through member expression #32937
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
One thing that might prevent type parameters from flowing through is this: I don’t know if that’s your issue, but it’s the first thing that came to mind. |
@fatcerberus checked it out, if that was the case then my first example wouldn't work either, no? |
This piece of code is way too suspicious. It makes sense it infers There is no constraint so the constraint on It cannot infer In general, type inference flows from inner to outer. Constraints and whatnot change the rules a little. But, fundamentally, you're expecting behavior that is completely different from what TS has. TS doesn't say,
I'm on mobile so I'll take a closer look when I get home but those are my current thoughts |
@AnyhowStep it works fine on its' own without the chaining; and the |
This needs a reasonable-sized repro before we can look at it - once things get this long, 99 times out of 100 it is a problem with the code itself, not TS. |
@RyanCavanaugh fair, but why can't TS make up its' mind about what type |
Your |
TypeScript Version: 3.5.3
Search Terms: inference nested member
Code
The Playground link reproduces this issue, but here is the whole code.
Expected behavior:
The type argument
RespondToQuestion
passed toCommandHandler.create<RespondToQuestion>()
should flow all the way through consistently.Actual behavior:
When using certain patterns, TS will change the type to
unknown
.Additionally, it seems it can't make up its' mind. 😅 The error says
body
can't be inferred, and yet the tip gets it right.Playground Link: Playground
Related Issues: These look related: #30134, #16597
The text was updated successfully, but these errors were encountered: