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 be a suggestion #27624

Closed
sandersn opened this issue Oct 8, 2018 · 0 comments
Closed

infer-from-usage codefix should be a suggestion #27624

sandersn opened this issue Oct 8, 2018 · 0 comments
Labels
feature-request A request for a new feature Suggestion An idea for TypeScript

Comments

@sandersn
Copy link
Member

sandersn commented Oct 8, 2018

Search Terms

infer from usage suggestion

Suggestion

The infer from usage codefix only triggers from noImplicitAny errors, which are only available with noImplicitAny on. In particular, this makes it a lot less likely that JS users will use the codefix after #27610 is merged. Instead, noImplicitAny errors should be suggestions, which can trigger.

Use Cases

function f(x) {
  return x + 1
}
// in JS, the codefix should produce this:
/**
 * @param {number} x
 */
function f(x) {
  return x + 1
}

This suggestion has a couple of problems:

  1. It would be difficult or at least slow to generate no-implicit-any errors without noImplicitAny: true, since the code paths are often quite different.
  2. inferFromUsage is not quite mature enough to be suggested everywhere to everybody all the time.

I'm working on (2), and (1) might not actually be a problem. A prototype is probably a good next step.

@sandersn sandersn added Suggestion An idea for TypeScript feature-request A request for a new feature labels Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for a new feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

1 participant