File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ namespace ts {
171171 node = getParseTreeNode(node, isExpression);
172172 return node ? getContextualType(node) : undefined;
173173 },
174+ isContextSensitive,
174175 getFullyQualifiedName,
175176 getResolvedSignature: (node, candidatesOutArray, theArgumentCount) => {
176177 node = getParseTreeNode(node, isCallLikeExpression);
Original file line number Diff line number Diff line change @@ -2739,6 +2739,8 @@ namespace ts {
27392739 getAugmentedPropertiesOfType ( type : Type ) : Symbol [ ] ;
27402740 getRootSymbols ( symbol : Symbol ) : Symbol [ ] ;
27412741 getContextualType ( node : Expression ) : Type | undefined ;
2742+ /* @internal */ isContextSensitive ( node : Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike ) : boolean ;
2743+
27422744 /**
27432745 * returns unknownSignature in the case of an error.
27442746 * @param argumentCount Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`.
Original file line number Diff line number Diff line change @@ -1004,7 +1004,7 @@ namespace ts.refactor.extractSymbol {
10041004 const localNameText = getUniqueName ( isClassLike ( scope ) ? "newProperty" : "newLocal" , file . text ) ;
10051005 const isJS = isInJavaScriptFile ( scope ) ;
10061006
1007- const variableType = isJS
1007+ const variableType = isJS || ! checker . isContextSensitive ( node )
10081008 ? undefined
10091009 : checker . typeToTypeNode ( checker . getContextualType ( node ) , scope , NodeBuilderFlags . NoTruncation ) ;
10101010
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const i = 0;
1515class C {
1616 M ( ) {
1717 for ( let j = 0 ; j < 10 ; j ++ ) {
18- const newLocal : any = i + 1 ;
18+ const newLocal = i + 1 ;
1919 x = /*RENAME*/ newLocal ;
2020 }
2121 }
@@ -25,7 +25,7 @@ class C {
2525
2626const i = 0 ;
2727class C {
28- private readonly newProperty : any = i + 1 ;
28+ private readonly newProperty = i + 1 ;
2929
3030 M ( ) {
3131 for ( let j = 0 ; j < 10 ; j ++ ) {
@@ -37,7 +37,7 @@ class C {
3737// ==SCOPE::Extract to constant in global scope==
3838
3939const i = 0 ;
40- const newLocal : any = i + 1 ;
40+ const newLocal = i + 1 ;
4141class C {
4242 M ( ) {
4343 for ( let j = 0 ; j < 10 ; j ++ ) {
You can’t perform that action at this time.
0 commit comments