File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -728,6 +728,11 @@ function parseUnaryExpression(operator: string): UnaryExpression {
728
728
729
729
function parsePrimaryExpression(): any {
730
730
throw "Not implemented";
731
+ }` ) ;
732
+ // Type parameter as declared type
733
+ testExtractMethod ( "extractMethod30" ,
734
+ `function F<T>() {
735
+ [#|let t: T;|]
731
736
}` ) ;
732
737
} ) ;
733
738
Original file line number Diff line number Diff line change @@ -1222,7 +1222,11 @@ namespace ts.refactor.extractMethod {
1222
1222
substitutionsPerScope [ i ] . set ( symbolId , substitution ) ;
1223
1223
}
1224
1224
else if ( isTypeName ) {
1225
- errorsPerScope [ i ] . push ( createDiagnosticForNode ( identifier , Messages . TypeWillNotBeVisibleInTheNewScope ) ) ;
1225
+ // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument
1226
+ // so there's no problem.
1227
+ if ( ! ( symbol . flags & SymbolFlags . TypeParameter ) ) {
1228
+ errorsPerScope [ i ] . push ( createDiagnosticForNode ( identifier , Messages . TypeWillNotBeVisibleInTheNewScope ) ) ;
1229
+ }
1226
1230
}
1227
1231
else {
1228
1232
usagesPerScope [ i ] . usages . set ( identifier . text as string , { usage, symbol, node : identifier } ) ;
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ function F < T > ( ) {
3
+ let t : T ;
4
+ }
5
+ // ==SCOPE::inner function in function 'F'==
6
+ function F < T > ( ) {
7
+ /*RENAME*/ newFunction ( ) ;
8
+
9
+ function newFunction ( ) {
10
+ let t : T ;
11
+ }
12
+ }
13
+ // ==SCOPE::function in global scope==
14
+ function F < T > ( ) {
15
+ /*RENAME*/ newFunction < T > ( ) ;
16
+ }
17
+ function newFunction < T > ( ) {
18
+ let t : T ;
19
+ }
You can’t perform that action at this time.
0 commit comments