Skip to content

Suggestions for misspelled properties and variables (based on Levenshtein distance for variables/properties in scope) #15333

Closed

Description

Consider the following code:

class X {
  public longName = 10;
  public otherName = 11;

  public do(){
    this.lognName = 20;
  }
}

Currently compilation fails with the message:

Property 'lognName' does not exist on the type 'X'.

In case when a variable is misspelled, the error is even less helpful:

public longMethod(){
  let firstVariable = 10;
  let secondVariable = "hello,world";
  
  //lots of code here
  fristVariable = 20;
}
Cannot find name 'fristVariable'.

It could offer variable/property suggestion, like:

Cannot find name 'fristVariable'. Did you mean 'firstVariable'?

For example, Rust compiler (1.16) would suggest an existing variable that most resembles the misspelled one, based on Levenstein distance, if I'm correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

CommittedThe team has roadmapped this issueFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions