Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f45df8f

Browse filesBrowse files
committed
Spelling code fix:suggestions from apparent type
The code fix for spelling correction needs to provide suggestions based on the apparent type since sometimes the type at a location will be a type parameter. One such example is `this`. Fixes microsoft#16744
1 parent c4319e3 commit f45df8f
Copy full SHA for f45df8f

2 files changed

+16-1Lines changed: 16 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/codefixes/fixSpelling.ts‎

Copy file name to clipboardExpand all lines: src/services/codefixes/fixSpelling.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ts.codefix {
1616
const checker = context.program.getTypeChecker();
1717
let suggestion: string;
1818
if (node.kind === SyntaxKind.Identifier && isPropertyAccessExpression(node.parent)) {
19-
const containingType = checker.getTypeAtLocation(node.parent.expression);
19+
const containingType = checker.getApparentType(checker.getTypeAtLocation(node.parent.expression));
2020
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
2121
}
2222
else {
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////[|class C {
4+
//// state = 'hi'
5+
//// doStuff() {
6+
//// this.start;
7+
//// }
8+
////}|]
9+
10+
verify.rangeAfterCodeFix(`class C {
11+
state = 'hi'
12+
doStuff() {
13+
this.state;
14+
}
15+
}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.