Skip to content

Commit 6e1e1e7

Browse files
committed
Merge branch 'master' into incrementalBuildInfo
2 parents ac55310 + a5f93ef commit 6e1e1e7

7 files changed

+123
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21641,7 +21641,7 @@ namespace ts {
2164121641
if (isTupleType(restType)) {
2164221642
const associatedNames = (<TupleType>(<TypeReference>restType).target).associatedNames;
2164321643
const index = pos - paramCount;
21644-
return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index as __String;
21644+
return associatedNames && associatedNames[index] || restParameter.escapedName + "_" + index as __String;
2164521645
}
2164621646
return restParameter.escapedName;
2164721647
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/compiler/getParameterNameAtPosition.ts(9,7): error TS2345: Argument of type 'Mock<[any]>' is not assignable to parameter of type 'Tester'.
2+
Types of parameters 'args_1' and 'done' are incompatible.
3+
Type '(...args: any[]) => any' is not assignable to type 'undefined'.
4+
5+
6+
==== tests/cases/compiler/getParameterNameAtPosition.ts (1 errors) ====
7+
// Repro from #30171
8+
9+
interface Mock<Y extends any[]> extends Function {
10+
(...args: Y): any;
11+
}
12+
type Tester = (opts: any, done: (...args: any[]) => any) => any;
13+
declare function cases(tester: Tester): void;
14+
declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>;
15+
cases(fn(opts => { }));
16+
~~~~~~~~~~~~~~~
17+
!!! error TS2345: Argument of type 'Mock<[any]>' is not assignable to parameter of type 'Tester'.
18+
!!! error TS2345: Types of parameters 'args_1' and 'done' are incompatible.
19+
!!! error TS2345: Type '(...args: any[]) => any' is not assignable to type 'undefined'.
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [getParameterNameAtPosition.ts]
2+
// Repro from #30171
3+
4+
interface Mock<Y extends any[]> extends Function {
5+
(...args: Y): any;
6+
}
7+
type Tester = (opts: any, done: (...args: any[]) => any) => any;
8+
declare function cases(tester: Tester): void;
9+
declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>;
10+
cases(fn(opts => { }));
11+
12+
13+
//// [getParameterNameAtPosition.js]
14+
"use strict";
15+
// Repro from #30171
16+
cases(fn(function (opts) { }));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=== tests/cases/compiler/getParameterNameAtPosition.ts ===
2+
// Repro from #30171
3+
4+
interface Mock<Y extends any[]> extends Function {
5+
>Mock : Symbol(Mock, Decl(getParameterNameAtPosition.ts, 0, 0))
6+
>Y : Symbol(Y, Decl(getParameterNameAtPosition.ts, 2, 15))
7+
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
8+
9+
(...args: Y): any;
10+
>args : Symbol(args, Decl(getParameterNameAtPosition.ts, 3, 5))
11+
>Y : Symbol(Y, Decl(getParameterNameAtPosition.ts, 2, 15))
12+
}
13+
type Tester = (opts: any, done: (...args: any[]) => any) => any;
14+
>Tester : Symbol(Tester, Decl(getParameterNameAtPosition.ts, 4, 1))
15+
>opts : Symbol(opts, Decl(getParameterNameAtPosition.ts, 5, 15))
16+
>done : Symbol(done, Decl(getParameterNameAtPosition.ts, 5, 25))
17+
>args : Symbol(args, Decl(getParameterNameAtPosition.ts, 5, 33))
18+
19+
declare function cases(tester: Tester): void;
20+
>cases : Symbol(cases, Decl(getParameterNameAtPosition.ts, 5, 64))
21+
>tester : Symbol(tester, Decl(getParameterNameAtPosition.ts, 6, 23))
22+
>Tester : Symbol(Tester, Decl(getParameterNameAtPosition.ts, 4, 1))
23+
24+
declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>;
25+
>fn : Symbol(fn, Decl(getParameterNameAtPosition.ts, 6, 45))
26+
>Y : Symbol(Y, Decl(getParameterNameAtPosition.ts, 7, 20))
27+
>implementation : Symbol(implementation, Decl(getParameterNameAtPosition.ts, 7, 37))
28+
>args : Symbol(args, Decl(getParameterNameAtPosition.ts, 7, 55))
29+
>Y : Symbol(Y, Decl(getParameterNameAtPosition.ts, 7, 20))
30+
>Mock : Symbol(Mock, Decl(getParameterNameAtPosition.ts, 0, 0))
31+
>Y : Symbol(Y, Decl(getParameterNameAtPosition.ts, 7, 20))
32+
33+
cases(fn(opts => { }));
34+
>cases : Symbol(cases, Decl(getParameterNameAtPosition.ts, 5, 64))
35+
>fn : Symbol(fn, Decl(getParameterNameAtPosition.ts, 6, 45))
36+
>opts : Symbol(opts, Decl(getParameterNameAtPosition.ts, 8, 9))
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/compiler/getParameterNameAtPosition.ts ===
2+
// Repro from #30171
3+
4+
interface Mock<Y extends any[]> extends Function {
5+
(...args: Y): any;
6+
>args : Y
7+
}
8+
type Tester = (opts: any, done: (...args: any[]) => any) => any;
9+
>Tester : Tester
10+
>opts : any
11+
>done : (...args: any[]) => any
12+
>args : any[]
13+
14+
declare function cases(tester: Tester): void;
15+
>cases : (tester: Tester) => void
16+
>tester : Tester
17+
18+
declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>;
19+
>fn : <Y extends any[]>(implementation?: ((...args: Y) => any) | undefined) => Mock<Y>
20+
>implementation : ((...args: Y) => any) | undefined
21+
>args : Y
22+
23+
cases(fn(opts => { }));
24+
>cases(fn(opts => { })) : void
25+
>cases : (tester: Tester) => void
26+
>fn(opts => { }) : Mock<[any]>
27+
>fn : <Y extends any[]>(implementation?: ((...args: Y) => any) | undefined) => Mock<Y>
28+
>opts => { } : (opts: any) => void
29+
>opts : any
30+

tests/baselines/reference/user/npm.log

+8
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ node_modules/npm/lib/pack.js(177,25): error TS2339: Property 'config' does not e
623623
node_modules/npm/lib/pack.js(299,17): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'.
624624
node_modules/npm/lib/pack.js(300,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
625625
node_modules/npm/lib/pack.js(300,36): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'.
626+
node_modules/npm/lib/pack.js(320,7): error TS2531: Object is possibly 'null'.
627+
node_modules/npm/lib/pack.js(325,7): error TS2531: Object is possibly 'null'.
626628
node_modules/npm/lib/pack.js(333,15): error TS2531: Object is possibly 'null'.
627629
node_modules/npm/lib/pack.js(335,17): error TS2339: Property 'code' does not exist on type 'Error'.
628630
node_modules/npm/lib/pack.js(336,17): error TS2339: Property 'signal' does not exist on type 'Error'.
@@ -944,6 +946,9 @@ node_modules/npm/test/need-npm5-update/legacy-optional-deps.js(12,21): error TS2
944946
node_modules/npm/test/need-npm5-update/legacy-shrinkwrap.js(2,20): error TS2307: Cannot find module 'tap'.
945947
node_modules/npm/test/need-npm5-update/legacy-shrinkwrap.js(6,21): error TS2307: Cannot find module 'tacks'.
946948
node_modules/npm/test/need-npm5-update/lifecycle-signal.js(8,20): error TS2307: Cannot find module 'tap'.
949+
node_modules/npm/test/need-npm5-update/lifecycle-signal.js(70,3): error TS2531: Object is possibly 'null'.
950+
node_modules/npm/test/need-npm5-update/lifecycle-signal.js(95,3): error TS2531: Object is possibly 'null'.
951+
node_modules/npm/test/need-npm5-update/lifecycle-signal.js(117,3): error TS2531: Object is possibly 'null'.
947952
node_modules/npm/test/need-npm5-update/move-no-clobber-dest-node-modules.js(3,20): error TS2307: Cannot find module 'tap'.
948953
node_modules/npm/test/need-npm5-update/move-no-clobber-dest-node-modules.js(11,48): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type 'string[]'.
949954
node_modules/npm/test/need-npm5-update/need-only-update-save-optional/update-save.js(5,18): error TS2307: Cannot find module 'npm-registry-mock'.
@@ -1712,6 +1717,7 @@ node_modules/npm/test/tap/version-from-git.js(202,7): error TS2339: Property 'lo
17121717
node_modules/npm/test/tap/version-from-git.js(213,7): error TS2339: Property 'load' does not exist on type 'typeof EventEmitter'.
17131718
node_modules/npm/test/tap/version-git-not-clean.js(2,20): error TS2307: Cannot find module 'tap'.
17141719
node_modules/npm/test/tap/version-git-not-clean.js(17,7): error TS2339: Property 'load' does not exist on type 'typeof EventEmitter'.
1720+
node_modules/npm/test/tap/version-git-not-clean.js(28,13): error TS2531: Object is possibly 'null'.
17151721
node_modules/npm/test/tap/version-git-not-clean.js(42,17): error TS2339: Property 'commands' does not exist on type 'typeof EventEmitter'.
17161722
node_modules/npm/test/tap/version-lifecycle.js(7,20): error TS2307: Cannot find module 'tap'.
17171723
node_modules/npm/test/tap/version-lifecycle.js(28,7): error TS2339: Property 'load' does not exist on type 'typeof EventEmitter'.
@@ -1726,6 +1732,8 @@ node_modules/npm/test/tap/version-no-git.js(17,7): error TS2339: Property 'load'
17261732
node_modules/npm/test/tap/version-no-package.js(2,20): error TS2307: Cannot find module 'tap'.
17271733
node_modules/npm/test/tap/version-no-tags.js(2,20): error TS2307: Cannot find module 'tap'.
17281734
node_modules/npm/test/tap/version-no-tags.js(17,7): error TS2339: Property 'load' does not exist on type 'typeof EventEmitter'.
1735+
node_modules/npm/test/tap/version-no-tags.js(23,9): error TS2531: Object is possibly 'null'.
1736+
node_modules/npm/test/tap/version-no-tags.js(32,7): error TS2531: Object is possibly 'null'.
17291737
node_modules/npm/test/tap/version-no-tags.js(34,13): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'.
17301738
node_modules/npm/test/tap/version-no-tags.js(35,13): error TS2339: Property 'commands' does not exist on type 'typeof EventEmitter'.
17311739
node_modules/npm/test/tap/version-sub-directory-shrinkwrap.js(8,20): error TS2307: Cannot find module 'tap'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @strict: true
2+
3+
// Repro from #30171
4+
5+
interface Mock<Y extends any[]> extends Function {
6+
(...args: Y): any;
7+
}
8+
type Tester = (opts: any, done: (...args: any[]) => any) => any;
9+
declare function cases(tester: Tester): void;
10+
declare function fn<Y extends any[]>(implementation?: (...args: Y) => any): Mock<Y>;
11+
cases(fn(opts => { }));

0 commit comments

Comments
 (0)