Skip to content

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

Closed
@sandersn

Description

@sandersn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions