From e0bf2670294944eb7f9af1498f10cd346e1b333b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 30 Jun 2017 10:11:00 -0700 Subject: [PATCH] spelling:getPropertiesOfType instead of objectType This provides suggestions for more types based on their apparent type: unions, type parameters with constraints, primitives. --- src/compiler/checker.ts | 2 +- src/services/codefixes/fixSpelling.ts | 2 +- .../{codeFixCorrectSpelling.ts => codeFixCorrectSpelling1.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/cases/fourslash/{codeFixCorrectSpelling.ts => codeFixCorrectSpelling1.ts} (100%) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 64e61e15dfd..aebdad4822f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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; } diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index d632671f6ee..c8f539e8d34 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -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 { diff --git a/tests/cases/fourslash/codeFixCorrectSpelling.ts b/tests/cases/fourslash/codeFixCorrectSpelling1.ts similarity index 100% rename from tests/cases/fourslash/codeFixCorrectSpelling.ts rename to tests/cases/fourslash/codeFixCorrectSpelling1.ts