diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 971d918cb33..36f739113ab 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -544,6 +544,27 @@ namespace A { return a1.x + 10;|] } } +}`); + // The "b" type parameters aren't used and shouldn't be passed to the extracted function. + // Type parameters should be in syntactic order (i.e. in order or character offset from BOF). + // In all cases, we could use type inference, rather than passing explicit type arguments. + // Note the inclusion of arrow functions to ensure that some type parameters are not from + // targetable scopes. + testExtractMethod("extractMethod13", + `(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + [#|t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString();|] + } + } + } + } }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts new file mode 100644 index 00000000000..8f76dea88aa --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -0,0 +1,75 @@ +// ==ORIGINAL== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); + } + } + } + } +} +// ==SCOPE::function 'F2'== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + newFunction(u3a); + } + + function newFunction(u3a: U3a) { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); + } + } + } + } +} +// ==SCOPE::function 'F1'== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + newFunction(t2a, u2a, u3a); + } + } + } + + function newFunction(t2a: T2a, u2a: U2a, u3a: U3a) { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); + } + } +} +// ==SCOPE::global scope== +(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + newFunction(t1a, t2a, u1a, u2a, u3a); + } + } + } + } +} +function newFunction(t1a: T1a, t2a: T2a, u1a: U1a, u2a: U2a, u3a: U3a) { + t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString(); +}