Skip to content

Commit c3f8904

Browse files
even more tests
1 parent 6b1af9b commit c3f8904

File tree

4 files changed

+60
-16
lines changed

4 files changed

+60
-16
lines changed

tests/baselines/reference/dontWiden.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const d = { a: 1, b: 'c' };
44

55
interface SomeInterface { a: boolean }
66
declare function foo<T extends any[]>(arg: T): { hi: T };
7+
declare function boo<T extends number[]>(arg: T): { hi: T };
78
declare function bar(arg: SomeInterface): void
89
declare function baz(arg: [number, 2, 3 | number]): void
910
declare function bag(arg: number[]): void
@@ -19,6 +20,8 @@ bar({a: true});
1920
baz([1, 2, 3]);
2021
bag([1, 2, 3]);
2122
bag(e);
23+
boo([1, 2, 3]);
24+
boo(e);
2225

2326

2427
//// [dontWiden.js]
@@ -34,3 +37,5 @@ bar({ a: true });
3437
baz([1, 2, 3]);
3538
bag([1, 2, 3]);
3639
bag(e);
40+
boo([1, 2, 3]);
41+
boo(e);

tests/baselines/reference/dontWiden.symbols

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,61 @@ declare function foo<T extends any[]>(arg: T): { hi: T };
1919
>hi : Symbol(hi, Decl(dontWiden.ts, 4, 48))
2020
>T : Symbol(T, Decl(dontWiden.ts, 4, 21))
2121

22+
declare function boo<T extends number[]>(arg: T): { hi: T };
23+
>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57))
24+
>T : Symbol(T, Decl(dontWiden.ts, 5, 21))
25+
>arg : Symbol(arg, Decl(dontWiden.ts, 5, 41))
26+
>T : Symbol(T, Decl(dontWiden.ts, 5, 21))
27+
>hi : Symbol(hi, Decl(dontWiden.ts, 5, 51))
28+
>T : Symbol(T, Decl(dontWiden.ts, 5, 21))
29+
2230
declare function bar(arg: SomeInterface): void
23-
>bar : Symbol(bar, Decl(dontWiden.ts, 4, 57))
24-
>arg : Symbol(arg, Decl(dontWiden.ts, 5, 21))
31+
>bar : Symbol(bar, Decl(dontWiden.ts, 5, 60))
32+
>arg : Symbol(arg, Decl(dontWiden.ts, 6, 21))
2533
>SomeInterface : Symbol(SomeInterface, Decl(dontWiden.ts, 1, 27))
2634

2735
declare function baz(arg: [number, 2, 3 | number]): void
28-
>baz : Symbol(baz, Decl(dontWiden.ts, 5, 46))
29-
>arg : Symbol(arg, Decl(dontWiden.ts, 6, 21))
36+
>baz : Symbol(baz, Decl(dontWiden.ts, 6, 46))
37+
>arg : Symbol(arg, Decl(dontWiden.ts, 7, 21))
3038

3139
declare function bag(arg: number[]): void
32-
>bag : Symbol(bag, Decl(dontWiden.ts, 6, 56))
33-
>arg : Symbol(arg, Decl(dontWiden.ts, 7, 21))
40+
>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56))
41+
>arg : Symbol(arg, Decl(dontWiden.ts, 8, 21))
3442

3543
// As variable assignees
3644
const a: number[] = [1, 2, 3];
37-
>a : Symbol(a, Decl(dontWiden.ts, 10, 5))
45+
>a : Symbol(a, Decl(dontWiden.ts, 11, 5))
3846

3947
const b: SomeInterface = {a: true};
40-
>b : Symbol(b, Decl(dontWiden.ts, 11, 5))
48+
>b : Symbol(b, Decl(dontWiden.ts, 12, 5))
4149
>SomeInterface : Symbol(SomeInterface, Decl(dontWiden.ts, 1, 27))
42-
>a : Symbol(a, Decl(dontWiden.ts, 11, 26))
50+
>a : Symbol(a, Decl(dontWiden.ts, 12, 26))
4351

4452
const e = [1, 2, 3];
45-
>e : Symbol(e, Decl(dontWiden.ts, 12, 5))
53+
>e : Symbol(e, Decl(dontWiden.ts, 13, 5))
4654

4755
// Same, but as arguments
4856
foo([1, 2, 3]);
4957
>foo : Symbol(foo, Decl(dontWiden.ts, 3, 38))
5058

5159
bar({a: true});
52-
>bar : Symbol(bar, Decl(dontWiden.ts, 4, 57))
53-
>a : Symbol(a, Decl(dontWiden.ts, 16, 5))
60+
>bar : Symbol(bar, Decl(dontWiden.ts, 5, 60))
61+
>a : Symbol(a, Decl(dontWiden.ts, 17, 5))
5462

5563
baz([1, 2, 3]);
56-
>baz : Symbol(baz, Decl(dontWiden.ts, 5, 46))
64+
>baz : Symbol(baz, Decl(dontWiden.ts, 6, 46))
5765

5866
bag([1, 2, 3]);
59-
>bag : Symbol(bag, Decl(dontWiden.ts, 6, 56))
67+
>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56))
6068

6169
bag(e);
62-
>bag : Symbol(bag, Decl(dontWiden.ts, 6, 56))
63-
>e : Symbol(e, Decl(dontWiden.ts, 12, 5))
70+
>bag : Symbol(bag, Decl(dontWiden.ts, 7, 56))
71+
>e : Symbol(e, Decl(dontWiden.ts, 13, 5))
72+
73+
boo([1, 2, 3]);
74+
>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57))
75+
76+
boo(e);
77+
>boo : Symbol(boo, Decl(dontWiden.ts, 4, 57))
78+
>e : Symbol(e, Decl(dontWiden.ts, 13, 5))
6479

tests/baselines/reference/dontWiden.types

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ declare function foo<T extends any[]>(arg: T): { hi: T };
2525
>hi : T
2626
>T : T
2727

28+
declare function boo<T extends number[]>(arg: T): { hi: T };
29+
>boo : <T extends number[]>(arg: T) => { hi: T; }
30+
>T : T
31+
>arg : T
32+
>T : T
33+
>hi : T
34+
>T : T
35+
2836
declare function bar(arg: SomeInterface): void
2937
>bar : (arg: SomeInterface) => void
3038
>arg : SomeInterface
@@ -97,3 +105,16 @@ bag(e);
97105
>bag : (arg: number[]) => void
98106
>e : [1, 2, 3]
99107

108+
boo([1, 2, 3]);
109+
>boo([1, 2, 3]) : { hi: [1, 2, 3]; }
110+
>boo : <T extends number[]>(arg: T) => { hi: T; }
111+
>[1, 2, 3] : [1, 2, 3]
112+
>1 : 1
113+
>2 : 2
114+
>3 : 3
115+
116+
boo(e);
117+
>boo(e) : { hi: [1, 2, 3]; }
118+
>boo : <T extends number[]>(arg: T) => { hi: T; }
119+
>e : [1, 2, 3]
120+

tests/cases/compiler/dontWiden.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const d = { a: 1, b: 'c' };
55

66
interface SomeInterface { a: boolean }
77
declare function foo<T extends any[]>(arg: T): { hi: T };
8+
declare function boo<T extends number[]>(arg: T): { hi: T };
89
declare function bar(arg: SomeInterface): void
910
declare function baz(arg: [number, 2, 3 | number]): void
1011
declare function bag(arg: number[]): void
@@ -20,3 +21,5 @@ bar({a: true});
2021
baz([1, 2, 3]);
2122
bag([1, 2, 3]);
2223
bag(e);
24+
boo([1, 2, 3]);
25+
boo(e);

0 commit comments

Comments
 (0)