Skip to content

Commit 623a172

Browse files
committed
Accept new baselines
1 parent d96d16e commit 623a172

File tree

4 files changed

+118
-17
lines changed

4 files changed

+118
-17
lines changed

tests/baselines/reference/unionTypeInference.errors.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference
3939
~~
4040
!!! error TS2345: Argument of type '42' is not assignable to parameter of type 'never'.
4141

42+
export interface Foo<T> {
43+
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
44+
}
45+
export interface Bar<T> {
46+
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
47+
}
48+
49+
function qux(p1: Foo<void>, p2: Bar<void>) {
50+
p1 = p2;
51+
}
52+
4253
// Repros from #32434
4354

4455
declare function foo<T>(x: T | Promise<T>): void;

tests/baselines/reference/unionTypeInference.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ const d1 = f4("abc");
3131
const d2 = f4(s);
3232
const d3 = f4(42); // Error
3333

34+
export interface Foo<T> {
35+
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
36+
}
37+
export interface Bar<T> {
38+
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
39+
}
40+
41+
function qux(p1: Foo<void>, p2: Bar<void>) {
42+
p1 = p2;
43+
}
44+
3445
// Repros from #32434
3546

3647
declare function foo<T>(x: T | Promise<T>): void;
@@ -43,6 +54,7 @@ const y = bar(1, 2);
4354

4455
//// [unionTypeInference.js]
4556
"use strict";
57+
exports.__esModule = true;
4658
var a1 = f1(1, 2); // 1 | 2
4759
var a2 = f1(1, "hello"); // 1
4860
var a3 = f1(1, sn); // number
@@ -59,5 +71,8 @@ var c5 = f3("abc"); // never
5971
var d1 = f4("abc");
6072
var d2 = f4(s);
6173
var d3 = f4(42); // Error
74+
function qux(p1, p2) {
75+
p1 = p2;
76+
}
6277
foo(x);
6378
var y = bar(1, 2);

tests/baselines/reference/unionTypeInference.symbols

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,83 @@ const d3 = f4(42); // Error
107107
>d3 : Symbol(d3, Decl(unionTypeInference.ts, 30, 5))
108108
>f4 : Symbol(f4, Decl(unionTypeInference.ts, 24, 21))
109109

110+
export interface Foo<T> {
111+
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
112+
>T : Symbol(T, Decl(unionTypeInference.ts, 32, 21))
113+
114+
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
115+
>then : Symbol(Foo.then, Decl(unionTypeInference.ts, 32, 25))
116+
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
117+
>f : Symbol(f, Decl(unionTypeInference.ts, 33, 12))
118+
>x : Symbol(x, Decl(unionTypeInference.ts, 33, 16))
119+
>T : Symbol(T, Decl(unionTypeInference.ts, 32, 21))
120+
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
121+
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
122+
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
123+
>g : Symbol(g, Decl(unionTypeInference.ts, 33, 36))
124+
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
125+
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
126+
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
127+
}
128+
export interface Bar<T> {
129+
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
130+
>T : Symbol(T, Decl(unionTypeInference.ts, 35, 21))
131+
132+
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
133+
>then : Symbol(Bar.then, Decl(unionTypeInference.ts, 35, 25))
134+
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
135+
>f : Symbol(f, Decl(unionTypeInference.ts, 36, 12))
136+
>x : Symbol(x, Decl(unionTypeInference.ts, 36, 16))
137+
>T : Symbol(T, Decl(unionTypeInference.ts, 35, 21))
138+
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
139+
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
140+
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
141+
>g : Symbol(g, Decl(unionTypeInference.ts, 36, 36))
142+
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
143+
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
144+
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
145+
}
146+
147+
function qux(p1: Foo<void>, p2: Bar<void>) {
148+
>qux : Symbol(qux, Decl(unionTypeInference.ts, 37, 1))
149+
>p1 : Symbol(p1, Decl(unionTypeInference.ts, 39, 13))
150+
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
151+
>p2 : Symbol(p2, Decl(unionTypeInference.ts, 39, 27))
152+
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
153+
154+
p1 = p2;
155+
>p1 : Symbol(p1, Decl(unionTypeInference.ts, 39, 13))
156+
>p2 : Symbol(p2, Decl(unionTypeInference.ts, 39, 27))
157+
}
158+
110159
// Repros from #32434
111160

112161
declare function foo<T>(x: T | Promise<T>): void;
113-
>foo : Symbol(foo, Decl(unionTypeInference.ts, 30, 18))
114-
>T : Symbol(T, Decl(unionTypeInference.ts, 34, 21))
115-
>x : Symbol(x, Decl(unionTypeInference.ts, 34, 24))
116-
>T : Symbol(T, Decl(unionTypeInference.ts, 34, 21))
162+
>foo : Symbol(foo, Decl(unionTypeInference.ts, 41, 1))
163+
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
164+
>x : Symbol(x, Decl(unionTypeInference.ts, 45, 24))
165+
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
117166
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --))
118-
>T : Symbol(T, Decl(unionTypeInference.ts, 34, 21))
167+
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
119168

120169
declare let x: false | Promise<true>;
121-
>x : Symbol(x, Decl(unionTypeInference.ts, 35, 11))
170+
>x : Symbol(x, Decl(unionTypeInference.ts, 46, 11))
122171
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --))
123172

124173
foo(x);
125-
>foo : Symbol(foo, Decl(unionTypeInference.ts, 30, 18))
126-
>x : Symbol(x, Decl(unionTypeInference.ts, 35, 11))
174+
>foo : Symbol(foo, Decl(unionTypeInference.ts, 41, 1))
175+
>x : Symbol(x, Decl(unionTypeInference.ts, 46, 11))
127176

128177
declare function bar<T>(x: T, y: string | T): T;
129-
>bar : Symbol(bar, Decl(unionTypeInference.ts, 36, 7))
130-
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
131-
>x : Symbol(x, Decl(unionTypeInference.ts, 38, 24))
132-
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
133-
>y : Symbol(y, Decl(unionTypeInference.ts, 38, 29))
134-
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
135-
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
178+
>bar : Symbol(bar, Decl(unionTypeInference.ts, 47, 7))
179+
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
180+
>x : Symbol(x, Decl(unionTypeInference.ts, 49, 24))
181+
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
182+
>y : Symbol(y, Decl(unionTypeInference.ts, 49, 29))
183+
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
184+
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
136185

137186
const y = bar(1, 2);
138-
>y : Symbol(y, Decl(unionTypeInference.ts, 39, 5))
139-
>bar : Symbol(bar, Decl(unionTypeInference.ts, 36, 7))
187+
>y : Symbol(y, Decl(unionTypeInference.ts, 50, 5))
188+
>bar : Symbol(bar, Decl(unionTypeInference.ts, 47, 7))
140189

tests/baselines/reference/unionTypeInference.types

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,32 @@ const d3 = f4(42); // Error
131131
>f4 : <T>(x: string & T) => T
132132
>42 : 42
133133

134+
export interface Foo<T> {
135+
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
136+
>then : <U>(f: (x: T) => U | Foo<U>, g: U) => Foo<U>
137+
>f : (x: T) => U | Foo<U>
138+
>x : T
139+
>g : U
140+
}
141+
export interface Bar<T> {
142+
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
143+
>then : <S>(f: (x: T) => S | Bar<S>, g: S) => Bar<S>
144+
>f : (x: T) => S | Bar<S>
145+
>x : T
146+
>g : S
147+
}
148+
149+
function qux(p1: Foo<void>, p2: Bar<void>) {
150+
>qux : (p1: Foo<void>, p2: Bar<void>) => void
151+
>p1 : Foo<void>
152+
>p2 : Bar<void>
153+
154+
p1 = p2;
155+
>p1 = p2 : Bar<void>
156+
>p1 : Foo<void>
157+
>p2 : Bar<void>
158+
}
159+
134160
// Repros from #32434
135161

136162
declare function foo<T>(x: T | Promise<T>): void;

0 commit comments

Comments
 (0)