Unexpected type infer for function first argument with default value since 5.1 #57706
Open
1 of 5 tasks
Labels
Help Wanted
You can do this
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
🔎 Search Terms
"type infer first argument"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-dev.20240308#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXy1URBgEYAeAFQD4AKRVALngDEpMcYBPK6gSmaUAUKEiwEKdNjwEiJAEy96TVuwycuimgPjChIAB4AHThngYuRhGw7de8ALzxasAOalBAGnhv5zKKhcfI7UPoH6xqbmltZqGlqhTrQAdKluAM7MANqU3gFcALrBDqH5QuVgeOlmiKSOzgC26a7M1TCErvUA5AAWIBAQOF3eGCDV-oHFoQDe8AC+QpWo1T51ToTEZPSkfEIA9HvwR-AAegD8i1VmUPL1GwrbuwfHpxeXyzW3SU0t8G0d3T6AyGU3gswWSxWACM7nItoh5E9Dsdzu9oWtZJt5PREftkUdUWizGBYZtSLRaD9Whh2qhOk5ev1Bl1QeCkS9UZDiV9MQ9Kc1qbT6fBGcCWSEwfN2Si3kA
💻 Code
🙁 Actual behavior
In my code you'll notice that the type of
c
is not the same asb
, but the argument we passing into functioninfer1
is actually the same.I've tested this between v5.0.4 and v5.1.6, but the type of
c
is different:After checking v5.1 changelog, I'm still not sure what changes have been made between 5.0 to 5.1.
So I decided to submit this issue as a "Bug report".
🙂 Expected behavior
The type of
c
is supposed to bestring | undefined
.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: