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

infer-from-usage codefix should mark parameters as optional #28377

Open
sandersn opened this issue Nov 6, 2018 · 1 comment
Open

infer-from-usage codefix should mark parameters as optional #28377

sandersn opened this issue Nov 6, 2018 · 1 comment
Assignees
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@sandersn
Copy link
Member

sandersn commented Nov 6, 2018

Search Terms

codefix infer from usage optional parameter

Suggestion

When you ask to for the infer-from-usage codefix for f:

function f(x, y) {
  return x + (y || 0)
}
f(1)

You should get function f(x: number, y?: number | undefined)

This already works in JS. You get /** @param {number | undefined} [y] */.

@sandersn sandersn added Suggestion An idea for TypeScript Domain: Quick Fixes Editor-provided fixes, often called code actions. labels Nov 6, 2018
@sandersn sandersn self-assigned this Nov 6, 2018
@sandersn
Copy link
Member Author

sandersn commented Nov 6, 2018

@andy-ms points out that you might just want to see y?: number and the undefined should be dropped as well.

@weswigham weswigham added the In Discussion Not yet reached consensus label Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants