Skip to content

Commit 3bdfd8f

Browse files
committed
Make sure to instantiate merged type parameters
1 parent f95f51f commit 3bdfd8f

5 files changed

Lines changed: 72 additions & 1 deletion

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5464,7 +5464,7 @@ namespace ts {
54645464
const declaration = <DeclarationWithTypeParameters>node;
54655465
if (declaration.typeParameters) {
54665466
for (const d of declaration.typeParameters) {
5467-
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(d.symbol))) {
5467+
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getMergedSymbol(d.symbol)))) {
54685468
return true;
54695469
}
54705470
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [tests/cases/compiler/instantiateCrossFileMerge.ts] ////
2+
3+
//// [first.ts]
4+
declare class P<R> {
5+
constructor(callback: (resolve: (value: R) => void) => void);
6+
}
7+
8+
//// [second.ts]
9+
interface P<R> { }
10+
new P<string>(r => { r('foo') });
11+
12+
13+
//// [first.js]
14+
//// [second.js]
15+
new P(function (r) { r('foo'); });
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/first.ts ===
2+
declare class P<R> {
3+
>P : Symbol(P, Decl(first.ts, 0, 0), Decl(second.ts, 0, 0))
4+
>R : Symbol(R, Decl(first.ts, 0, 16), Decl(second.ts, 0, 12))
5+
6+
constructor(callback: (resolve: (value: R) => void) => void);
7+
>callback : Symbol(callback, Decl(first.ts, 1, 16))
8+
>resolve : Symbol(resolve, Decl(first.ts, 1, 27))
9+
>value : Symbol(value, Decl(first.ts, 1, 37))
10+
>R : Symbol(R, Decl(first.ts, 0, 16), Decl(second.ts, 0, 12))
11+
}
12+
13+
=== tests/cases/compiler/second.ts ===
14+
interface P<R> { }
15+
>P : Symbol(P, Decl(first.ts, 0, 0), Decl(second.ts, 0, 0))
16+
>R : Symbol(R, Decl(first.ts, 0, 16), Decl(second.ts, 0, 12))
17+
18+
new P<string>(r => { r('foo') });
19+
>P : Symbol(P, Decl(first.ts, 0, 0), Decl(second.ts, 0, 0))
20+
>r : Symbol(r, Decl(second.ts, 1, 14))
21+
>r : Symbol(r, Decl(second.ts, 1, 14))
22+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/compiler/first.ts ===
2+
declare class P<R> {
3+
>P : P<R>
4+
>R : R
5+
6+
constructor(callback: (resolve: (value: R) => void) => void);
7+
>callback : (resolve: (value: R) => void) => void
8+
>resolve : (value: R) => void
9+
>value : R
10+
>R : R
11+
}
12+
13+
=== tests/cases/compiler/second.ts ===
14+
interface P<R> { }
15+
>P : P<R>
16+
>R : R
17+
18+
new P<string>(r => { r('foo') });
19+
>new P<string>(r => { r('foo') }) : P<string>
20+
>P : typeof P
21+
>r => { r('foo') } : (r: (value: string) => void) => void
22+
>r : (value: string) => void
23+
>r('foo') : void
24+
>r : (value: string) => void
25+
>'foo' : string
26+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @filename: first.ts
2+
declare class P<R> {
3+
constructor(callback: (resolve: (value: R) => void) => void);
4+
}
5+
6+
// @filename: second.ts
7+
interface P<R> { }
8+
new P<string>(r => { r('foo') });

0 commit comments

Comments
 (0)