Skip to content
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

Allows you to configure functions not to pass arguments when they can be undefined #56632

Closed
guaijie opened this issue Dec 1, 2023 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@guaijie
Copy link

guaijie commented Dec 1, 2023

πŸ”Ž Search Terms

"undefined", "void", "optional", "no arguments", "rules"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about typescript

⏯ Playground Link

No response

πŸ’» Code

const fn1= (param: undefined | number) => {}
const fn2 = (param: undefined | number) => {}

πŸ™ Actual behavior

fn1(undefined) // success
fn1() // fail
fn2(undefined) //success
fn2() // success

πŸ™‚ Expected behavior

fn1(undefined) // success
fn1() // success 
fn2(undefined) //success
fn2() // success

Additional information about the issue

No response

@fatcerberus
Copy link

fatcerberus commented Dec 1, 2023

This is what optional parameters are for

const fn1 = (param?: number) => {};
fn1(undefined);  // works
fn1();           // also works

@jcalz
Copy link
Contributor

jcalz commented Dec 1, 2023

Duplicate of #12400

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 1, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants