spelling:getPropertiesOfType instead of objectType

This provides suggestions for more types based on their apparent type:
unions, type parameters with constraints, primitives.
This commit is contained in:
Nathan Shively-Sanders
2017-06-30 10:11:00 -07:00
parent f45df8fb69
commit e0bf267029
3 changed files with 2 additions and 2 deletions

View File

@@ -14504,7 +14504,7 @@ namespace ts {
}
function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined {
const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfObjectType(containingType), SymbolFlags.Value);
const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfType(containingType), SymbolFlags.Value);
return suggestion && suggestion.name;
}

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.getApparentType(checker.getTypeAtLocation(node.parent.expression));
const containingType = checker.getTypeAtLocation(node.parent.expression);
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
}
else {