TypeScript can't infer type of default parameters #59643
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
Uh oh!
There was an error while loading. Please reload this page.
🔎 Search Terms
infer default parameters
function wrapper
function factory
🕗 Version & Regression Information
Generator
type is not generic)⏯ Playground Link
https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVNQBEQYsA3EAHgEF4QAPDEVYAZ3jQGtUcB3VANoBdADTwASgD4AFACh4CggC540gHQbYAc1YrqASngBeSfADizElAw4YlLj35ipI2fpUO++APQAqX-AAtjhgnCDA8HAYyDD4vt4A3LKyiEQk5CDSKOjYePC+0lDG8AAMYgBGxQDkVYYA3vLwYHisOBAgahA4WtINivBQrvDe3vAAegD8jQrl8iPjUwoAvvpJK0lAA
💻 Code
🙁 Actual behavior
The type of
a
andb
isunknown
.🙂 Expected behavior
The type of
a
andb
should benumber
andstring
Additional information about the issue
I was working with a library
gensync
when I hit this issue, and I extracted the minimum reproduction out of it.Note that if I don't use default parameters, typescript can infer the
a
andb
types correctly:The text was updated successfully, but these errors were encountered: