-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More did-you-mean errors on classes in plain JS
Classes - that are declared with class declarations or expressions, but not constructor functions - and which have nothing in their heritage clauses Now provide spelling suggestions on misspelled property accesses. Because of JS support for assignment-as-declaration, it's still easy to mistakenly declare a property with a typo and not get any suggestions.
- Loading branch information
Showing
2 changed files
with
52 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,52 @@ | ||
/// <reference path='fourslash.ts' /> | ||
// @allowJs: true | ||
// @Filename: codeFixSpellingJs9.js | ||
//// class C { | ||
//// numble = 1 | ||
//// mumble() { | ||
//// return this.[|numbles|] | ||
//// } | ||
//// } | ||
//// class D extends C { } | ||
//// const c = new C() | ||
//// c.[|numbles|] = 3 | ||
//// c.[|mumbles|]() | ||
//// const d = new D() | ||
//// d.[|numbles|] = 4 | ||
//// d.[|mumbles()|] | ||
//// class Person { | ||
//// getFavoriteColor() { | ||
//// | ||
//// } | ||
//// } | ||
//// | ||
//// const person = new Person(); | ||
//// person.[|getFavoriteColour|](); | ||
//// person.[|getFavoriteColoxr|](); | ||
verify.codeFixAll({ | ||
fixId: "fixSpelling", | ||
fixAllDescription: "Fix all detected spelling errors", | ||
newFileContent: | ||
`class C { | ||
numble = 1 | ||
mumble() { | ||
return this.numble | ||
} | ||
} | ||
class D extends C { } | ||
const c = new C() | ||
c.numble = 3 | ||
c.mumble() | ||
const d = new D() | ||
d.numbles = 4 | ||
d.mumbles() | ||
class Person { | ||
getFavoriteColor() { | ||
// @allowjs: true | ||
// @noEmit: true | ||
} | ||
} | ||
// @filename: noSuggestionWithoutDidYouMean.js | ||
//// let a = {}; | ||
//// console.log(a.apple); | ||
verify.noErrors() | ||
verify.getSuggestionDiagnostics([]) | ||
const person = new Person(); | ||
person.getFavoriteColor(); | ||
person.getFavoriteColor();`, | ||
}); |