You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide high-confidence spelling suggestions as suggestion diagnostics #41582
When JavaScript users don't have type-checking turned on, there are often some good suggestions left on the table that go to waste.
Obviously we can't just provide all the errors that checkJs would issue, but there are a few good ones. Specifically, spelling suggestions could be provided if we were more confident in how useful they are, where confidence is determined by some rules.
Some of the following rules might be worth investigating:
the suggestion occurs in a module file
the "misspelled" identifier occurs nowhere else in the program
the "misspelled" identifier is not a commonly-used identifier in well-known libraries
the suggestion's edit distance is lower than the usual threshold
This is a new feature so I'm going to move it to 4.3.
Aside: I don't know that the suggestion would have to be any more accurate than a TS suggestion -- JS is a best-effort environment, where completions over-generate rather than under-generate. I think it would be fine for spelling suggestions to do the same, especially since the suggestion UI is unobtrusive in VS Code at least.
Filtering out identifiers used elsewhere and commonly used identifiers is a good idea, though.
However, since there are likely to be a lot of unresolved identifiers in JS files, it does make sense to limit the number of suggestions. Instead of starting from improving accuracy, I think it would work better to generate all the suggestions but only show the most valuable ones. (This would probably be harder and more expensive to implement, though.)
To reduce the number of suggestions, suggest only on property accesses. Object types have implicit index signatures outside strict, so that'll have to change.
To reduce the number of non-property-access suggestions, suggest only from local scope. (I'm not sure how easy this is to do.)
Note that the suggestion wording might need to change if we're not sure that the identifier in question really isn't found.
Activity
sandersn commentedon Feb 8, 2021
This is a new feature so I'm going to move it to 4.3.
Aside: I don't know that the suggestion would have to be any more accurate than a TS suggestion -- JS is a best-effort environment, where completions over-generate rather than under-generate. I think it would be fine for spelling suggestions to do the same, especially since the suggestion UI is unobtrusive in VS Code at least.
Filtering out identifiers used elsewhere and commonly used identifiers is a good idea, though.
sandersn commentedon Feb 8, 2021
However, since there are likely to be a lot of unresolved identifiers in JS files, it does make sense to limit the number of suggestions. Instead of starting from improving accuracy, I think it would work better to generate all the suggestions but only show the most valuable ones. (This would probably be harder and more expensive to implement, though.)
sandersn commentedon Feb 11, 2021
Few more thoughts:
strict, so that'll have to change.