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 #16744
This commit is contained in:
Nathan Shively-Sanders
2017-06-29 16:21:00 -07:00
parent c4319e3b94
commit f45df8fb69
2 changed files with 16 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ namespace ts.codefix {
const checker = context.program.getTypeChecker();
let suggestion: string;
if (node.kind === SyntaxKind.Identifier && isPropertyAccessExpression(node.parent)) {
const containingType = checker.getTypeAtLocation(node.parent.expression);
const containingType = checker.getApparentType(checker.getTypeAtLocation(node.parent.expression));
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
}
else {