diff --git a/tests/baselines/reference/dontWiden.js b/tests/baselines/reference/dontWiden.js index d4581913d1443..f9a19b5ab7320 100644 --- a/tests/baselines/reference/dontWiden.js +++ b/tests/baselines/reference/dontWiden.js @@ -4,6 +4,7 @@ const d = { a: 1, b: 'c' }; interface SomeInterface { a: boolean } declare function foo(arg: T): { hi: T }; +declare function boo(arg: T): { hi: T }; declare function bar(arg: SomeInterface): void declare function baz(arg: [number, 2, 3 | number]): void declare function bag(arg: number[]): void @@ -19,6 +20,8 @@ bar({a: true}); baz([1, 2, 3]); bag([1, 2, 3]); bag(e); +boo([1, 2, 3]); +boo(e); //// [dontWiden.js] @@ -34,3 +37,5 @@ bar({ a: true }); baz([1, 2, 3]); bag([1, 2, 3]); bag(e); +boo([1, 2, 3]); +boo(e); diff --git a/tests/baselines/reference/dontWiden.symbols b/tests/baselines/reference/dontWiden.symbols index ede7b6f989540..a38508e9696f4 100644 --- a/tests/baselines/reference/dontWiden.symbols +++ b/tests/baselines/reference/dontWiden.symbols @@ -19,46 +19,61 @@ declare function foo(arg: T): { hi: T }; >hi : Symbol(hi, Decl(dontWiden.ts, 4, 48)) >T : Symbol(T, Decl(dontWiden.ts, 4, 21)) +declare function boo(arg: T): { hi: T }; +>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57)) +>T : Symbol(T, Decl(dontWiden.ts, 5, 21)) +>arg : Symbol(arg, Decl(dontWiden.ts, 5, 41)) +>T : Symbol(T, Decl(dontWiden.ts, 5, 21)) +>hi : Symbol(hi, Decl(dontWiden.ts, 5, 51)) +>T : Symbol(T, Decl(dontWiden.ts, 5, 21)) + declare function bar(arg: SomeInterface): void ->bar : Symbol(bar, Decl(dontWiden.ts, 4, 57)) ->arg : Symbol(arg, Decl(dontWiden.ts, 5, 21)) +>bar : Symbol(bar, Decl(dontWiden.ts, 5, 60)) +>arg : Symbol(arg, Decl(dontWiden.ts, 6, 21)) >SomeInterface : Symbol(SomeInterface, Decl(dontWiden.ts, 1, 27)) declare function baz(arg: [number, 2, 3 | number]): void ->baz : Symbol(baz, Decl(dontWiden.ts, 5, 46)) ->arg : Symbol(arg, Decl(dontWiden.ts, 6, 21)) +>baz : Symbol(baz, Decl(dontWiden.ts, 6, 46)) +>arg : Symbol(arg, Decl(dontWiden.ts, 7, 21)) declare function bag(arg: number[]): void ->bag : Symbol(bag, Decl(dontWiden.ts, 6, 56)) ->arg : Symbol(arg, Decl(dontWiden.ts, 7, 21)) +>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56)) +>arg : Symbol(arg, Decl(dontWiden.ts, 8, 21)) // As variable assignees const a: number[] = [1, 2, 3]; ->a : Symbol(a, Decl(dontWiden.ts, 10, 5)) +>a : Symbol(a, Decl(dontWiden.ts, 11, 5)) const b: SomeInterface = {a: true}; ->b : Symbol(b, Decl(dontWiden.ts, 11, 5)) +>b : Symbol(b, Decl(dontWiden.ts, 12, 5)) >SomeInterface : Symbol(SomeInterface, Decl(dontWiden.ts, 1, 27)) ->a : Symbol(a, Decl(dontWiden.ts, 11, 26)) +>a : Symbol(a, Decl(dontWiden.ts, 12, 26)) const e = [1, 2, 3]; ->e : Symbol(e, Decl(dontWiden.ts, 12, 5)) +>e : Symbol(e, Decl(dontWiden.ts, 13, 5)) // Same, but as arguments foo([1, 2, 3]); >foo : Symbol(foo, Decl(dontWiden.ts, 3, 38)) bar({a: true}); ->bar : Symbol(bar, Decl(dontWiden.ts, 4, 57)) ->a : Symbol(a, Decl(dontWiden.ts, 16, 5)) +>bar : Symbol(bar, Decl(dontWiden.ts, 5, 60)) +>a : Symbol(a, Decl(dontWiden.ts, 17, 5)) baz([1, 2, 3]); ->baz : Symbol(baz, Decl(dontWiden.ts, 5, 46)) +>baz : Symbol(baz, Decl(dontWiden.ts, 6, 46)) bag([1, 2, 3]); ->bag : Symbol(bag, Decl(dontWiden.ts, 6, 56)) +>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56)) bag(e); ->bag : Symbol(bag, Decl(dontWiden.ts, 6, 56)) ->e : Symbol(e, Decl(dontWiden.ts, 12, 5)) +>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56)) +>e : Symbol(e, Decl(dontWiden.ts, 13, 5)) + +boo([1, 2, 3]); +>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57)) + +boo(e); +>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57)) +>e : Symbol(e, Decl(dontWiden.ts, 13, 5)) diff --git a/tests/baselines/reference/dontWiden.types b/tests/baselines/reference/dontWiden.types index 5c222cf71ed9f..40ffa6344b583 100644 --- a/tests/baselines/reference/dontWiden.types +++ b/tests/baselines/reference/dontWiden.types @@ -25,6 +25,14 @@ declare function foo(arg: T): { hi: T }; >hi : T >T : T +declare function boo(arg: T): { hi: T }; +>boo : (arg: T) => { hi: T; } +>T : T +>arg : T +>T : T +>hi : T +>T : T + declare function bar(arg: SomeInterface): void >bar : (arg: SomeInterface) => void >arg : SomeInterface @@ -97,3 +105,16 @@ bag(e); >bag : (arg: number[]) => void >e : [1, 2, 3] +boo([1, 2, 3]); +>boo([1, 2, 3]) : { hi: [1, 2, 3]; } +>boo : (arg: T) => { hi: T; } +>[1, 2, 3] : [1, 2, 3] +>1 : 1 +>2 : 2 +>3 : 3 + +boo(e); +>boo(e) : { hi: [1, 2, 3]; } +>boo : (arg: T) => { hi: T; } +>e : [1, 2, 3] + diff --git a/tests/cases/compiler/dontWiden.ts b/tests/cases/compiler/dontWiden.ts index 26b1719b6a791..fb437c733a072 100644 --- a/tests/cases/compiler/dontWiden.ts +++ b/tests/cases/compiler/dontWiden.ts @@ -5,6 +5,7 @@ const d = { a: 1, b: 'c' }; interface SomeInterface { a: boolean } declare function foo(arg: T): { hi: T }; +declare function boo(arg: T): { hi: T }; declare function bar(arg: SomeInterface): void declare function baz(arg: [number, 2, 3 | number]): void declare function bag(arg: number[]): void @@ -20,3 +21,5 @@ bar({a: true}); baz([1, 2, 3]); bag([1, 2, 3]); bag(e); +boo([1, 2, 3]); +boo(e);