Skip to content

Optional arguments sometimes unable to infer #53792

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

Closed
unional opened this issue Apr 15, 2023 · 3 comments
Closed

Optional arguments sometimes unable to infer #53792

unional opened this issue Apr 15, 2023 · 3 comments

Comments

@unional
Copy link
Contributor

unional commented Apr 15, 2023

Bug Report

🔎 Search Terms

infer optional arguments parameters.

Here are some issues that might be related:

But this case is even simpler.

🕗 Version & Regression Information

4.8.4 - 5.0.4

It is working correctly in 4.7.4

  • This changed between versions 4.7.4 and 4.8.4

⏯ Playground Link

Playground link with relevant code

💻 Code

function define<P extends unknown[], Result>(fn: (...args: P) => Result): typeof fn { return fn }


// (optional?: { a: number; } | undefined) => void
const fn1 = define((optional?: { a: number }) => { })

// () => { foo(): void; }
const fn2 = define((optional?: { a: number }) => ({ foo() { } }))

🙁 Actual behavior

// () => { foo(): void; }
const fn2 = define((optional?: { a: number }) => ({ foo() { } }))

🙂 Expected behavior

// (optional?: { a: number; } | undefined) => { foo(): void; }
const fn2 = define((optional?: { a: number }) => ({ foo() { } }))
@jakebailey
Copy link
Member

Check nightly; the behavior should be fixed. (On my phone or I'd bisect it.)

@unional
Copy link
Contributor Author

unional commented Apr 16, 2023

Yes, confirmed it is fixed in nightly 20130415 20230415

@unional unional closed this as completed Apr 16, 2023
@fatcerberus
Copy link

fatcerberus commented Apr 16, 2023

nightly 20130415

2013?
Those TypeScript devs are something else, fixing bugs retroactively

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants