Make sure to instantiate merged type parameters

This commit is contained in:
Nathan Shively-Sanders 2016-05-20 10:59:05 -07:00
parent f95f51fefc
commit 3bdfd8f477
5 changed files with 72 additions and 1 deletions

View file

@ -5464,7 +5464,7 @@ namespace ts {
const declaration = <DeclarationWithTypeParameters>node;
if (declaration.typeParameters) {
for (const d of declaration.typeParameters) {
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(d.symbol))) {
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getMergedSymbol(d.symbol)))) {
return true;
}
}

View file

@ -0,0 +1,15 @@
//// [tests/cases/compiler/instantiateCrossFileMerge.ts] ////
//// [first.ts]
declare class P<R> {
constructor(callback: (resolve: (value: R) => void) => void);
}
//// [second.ts]
interface P<R> { }
new P<string>(r => { r('foo') });
//// [first.js]
//// [second.js]
new P(function (r) { r('foo'); });

View file

@ -0,0 +1,22 @@
=== tests/cases/compiler/first.ts ===
declare class P<R> {
>P : Symbol(P, Decl(first.ts, 0, 0), Decl(second.ts, 0, 0))
>R : Symbol(R, Decl(first.ts, 0, 16), Decl(second.ts, 0, 12))
constructor(callback: (resolve: (value: R) => void) => void);
>callback : Symbol(callback, Decl(first.ts, 1, 16))
>resolve : Symbol(resolve, Decl(first.ts, 1, 27))
>value : Symbol(value, Decl(first.ts, 1, 37))
>R : Symbol(R, Decl(first.ts, 0, 16), Decl(second.ts, 0, 12))
}
=== tests/cases/compiler/second.ts ===
interface P<R> { }
>P : Symbol(P, Decl(first.ts, 0, 0), Decl(second.ts, 0, 0))
>R : Symbol(R, Decl(first.ts, 0, 16), Decl(second.ts, 0, 12))
new P<string>(r => { r('foo') });
>P : Symbol(P, Decl(first.ts, 0, 0), Decl(second.ts, 0, 0))
>r : Symbol(r, Decl(second.ts, 1, 14))
>r : Symbol(r, Decl(second.ts, 1, 14))

View file

@ -0,0 +1,26 @@
=== tests/cases/compiler/first.ts ===
declare class P<R> {
>P : P<R>
>R : R
constructor(callback: (resolve: (value: R) => void) => void);
>callback : (resolve: (value: R) => void) => void
>resolve : (value: R) => void
>value : R
>R : R
}
=== tests/cases/compiler/second.ts ===
interface P<R> { }
>P : P<R>
>R : R
new P<string>(r => { r('foo') });
>new P<string>(r => { r('foo') }) : P<string>
>P : typeof P
>r => { r('foo') } : (r: (value: string) => void) => void
>r : (value: string) => void
>r('foo') : void
>r : (value: string) => void
>'foo' : string

View file

@ -0,0 +1,8 @@
// @filename: first.ts
declare class P<R> {
constructor(callback: (resolve: (value: R) => void) => void);
}
// @filename: second.ts
interface P<R> { }
new P<string>(r => { r('foo') });