Annotate fewer extracted constants with types

Expose `isContextSensitive` from the checker and omit type annotations
for expressions for which it returns false.
This commit is contained in:
Andrew Casey committed 2017-12-15 15:11:17 -08:00
1 parent e9ac87c2d6
commit 9efab94dfd
4 files changed
+7 -4

No files matched your search

+1 -1
View File
@@ -1004,7 +1004,7 @@ namespace ts.refactor.extractSymbol {
const localNameText = getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file.text);
const isJS = isInJavaScriptFile(scope);
const variableType = isJS
const variableType = isJS || !checker.isContextSensitive(node)
? undefined
: checker.typeToTypeNode(checker.getContextualType(node), scope, NodeBuilderFlags.NoTruncation);