Different inference behaviour between JSX and function call with context sensitive functions. #50121
Labels
Experience Enhancement
Noncontroversial enhancements
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Milestone
Bug Report
🔎 Search Terms
type inference function arguments
,context sensitive function inference
🕗 Version & Regression Information
This is the behaviour in both 4.7.4 and 4.8.0 beta, none of the cases worked before 4.7.
This seems related to #48538
⏯ Playground Link
Playground link with relevant code
💻 Code
Note that
jsx
is set topreserve
.🙁 Actual behavior
state.key = value
fails withType 'unknown' is not assignable to type 'number'.(2322)
The
Component<T>
is inferred to beComponent<unknown>
🙂 Expected behavior
I would expect it to type check the same as
functionCall1
I'd expect
Component<T>
to be inferred to beComponent<number>
The text was updated successfully, but these errors were encountered: