Skip to content

Commit 42be36d

Browse files
committed
Accept new baselines
1 parent c581575 commit 42be36d

File tree

4 files changed

+152
-1
lines changed

4 files changed

+152
-1
lines changed

tests/baselines/reference/inferFromGenericFunctionReturnTypes3.errors.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(28,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"bar"'.
2+
tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(175,47): error TS2322: Type 'boolean' is not assignable to type 'true'.
3+
tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(180,26): error TS2322: Type '{ state: State.A; }[] | { state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
4+
Type '{ state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
5+
Type '{ state: State.B; }' is not assignable to type '{ state: State.A; }'.
6+
Types of property 'state' are incompatible.
7+
Type 'State.B' is not assignable to type 'State.A'.
28

39

4-
==== tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts (1 errors) ====
10+
==== tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts (3 errors) ====
511
// Repros from #5487
612

713
function truePromise(): Promise<true> {
@@ -174,4 +180,24 @@ tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(28,30): error TS234
174180
}
175181
]);
176182
};
183+
184+
// Breaking change repros from #29478
185+
186+
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
187+
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
188+
~~~~~~~~
189+
!!! error TS2322: Type 'boolean' is not assignable to type 'true'.
190+
!!! related TS6502 tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts:174:39: The expected type comes from the return type of this signature.
191+
192+
enum State { A, B }
193+
type Foo = { state: State }
194+
declare function bar<T>(f: () => T[]): T[];
195+
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
196+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197+
!!! error TS2322: Type '{ state: State.A; }[] | { state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
198+
!!! error TS2322: Type '{ state: State.B; }[]' is not assignable to type '{ state: State.A; }[]'.
199+
!!! error TS2322: Type '{ state: State.B; }' is not assignable to type '{ state: State.A; }'.
200+
!!! error TS2322: Types of property 'state' are incompatible.
201+
!!! error TS2322: Type 'State.B' is not assignable to type 'State.A'.
202+
!!! related TS6502 tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts:179:28: The expected type comes from the return type of this signature.
177203

tests/baselines/reference/inferFromGenericFunctionReturnTypes3.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ const f1: F = () => {
169169
}
170170
]);
171171
};
172+
173+
// Breaking change repros from #29478
174+
175+
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
176+
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
177+
178+
enum State { A, B }
179+
type Foo = { state: State }
180+
declare function bar<T>(f: () => T[]): T[];
181+
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
172182

173183

174184
//// [inferFromGenericFunctionReturnTypes3.js]
@@ -261,6 +271,13 @@ const f1 = () => {
261271
}
262272
]);
263273
};
274+
let res = foldLeft(true, (acc, t) => acc && t); // Error
275+
var State;
276+
(function (State) {
277+
State[State["A"] = 0] = "A";
278+
State[State["B"] = 1] = "B";
279+
})(State || (State = {}));
280+
let x = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
264281

265282

266283
//// [inferFromGenericFunctionReturnTypes3.d.ts]

tests/baselines/reference/inferFromGenericFunctionReturnTypes3.symbols

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,55 @@ const f1: F = () => {
407407
]);
408408
};
409409

410+
// Breaking change repros from #29478
411+
412+
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
413+
>foldLeft : Symbol(foldLeft, Decl(inferFromGenericFunctionReturnTypes3.ts, 169, 2))
414+
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
415+
>z : Symbol(z, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 29))
416+
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
417+
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 34))
418+
>acc : Symbol(acc, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 39))
419+
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
420+
>t : Symbol(t, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 46))
421+
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
422+
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 173, 26))
423+
424+
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
425+
>res : Symbol(res, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 3))
426+
>foldLeft : Symbol(foldLeft, Decl(inferFromGenericFunctionReturnTypes3.ts, 169, 2))
427+
>acc : Symbol(acc, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 35))
428+
>t : Symbol(t, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 39))
429+
>acc : Symbol(acc, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 35))
430+
>t : Symbol(t, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 39))
431+
432+
enum State { A, B }
433+
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
434+
>A : Symbol(State.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 12))
435+
>B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
436+
437+
type Foo = { state: State }
438+
>Foo : Symbol(Foo, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 19))
439+
>state : Symbol(state, Decl(inferFromGenericFunctionReturnTypes3.ts, 177, 12))
440+
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
441+
442+
declare function bar<T>(f: () => T[]): T[];
443+
>bar : Symbol(bar, Decl(inferFromGenericFunctionReturnTypes3.ts, 177, 27))
444+
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 21))
445+
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 24))
446+
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 21))
447+
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 178, 21))
448+
449+
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
450+
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 3))
451+
>Foo : Symbol(Foo, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 19))
452+
>bar : Symbol(bar, Decl(inferFromGenericFunctionReturnTypes3.ts, 177, 27))
453+
>state : Symbol(state, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 36))
454+
>State.A : Symbol(State.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 12))
455+
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
456+
>A : Symbol(State.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 12))
457+
>state : Symbol(state, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 59))
458+
>State.B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
459+
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
460+
>B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
461+

tests/baselines/reference/inferFromGenericFunctionReturnTypes3.types

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,59 @@ const f1: F = () => {
450450
]);
451451
};
452452

453+
// Breaking change repros from #29478
454+
455+
declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
456+
>foldLeft : <U>(z: U, f: (acc: U, t: boolean) => U) => U
457+
>z : U
458+
>f : (acc: U, t: boolean) => U
459+
>acc : U
460+
>t : boolean
461+
462+
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Error
463+
>res : boolean
464+
>foldLeft(true, (acc, t) => acc && t) : any
465+
>foldLeft : <U>(z: U, f: (acc: U, t: boolean) => U) => U
466+
>true : true
467+
>(acc, t) => acc && t : (acc: true, t: boolean) => boolean
468+
>acc : true
469+
>t : boolean
470+
>acc && t : boolean
471+
>acc : true
472+
>t : boolean
473+
474+
enum State { A, B }
475+
>State : State
476+
>A : State.A
477+
>B : State.B
478+
479+
type Foo = { state: State }
480+
>Foo : Foo
481+
>state : State
482+
483+
declare function bar<T>(f: () => T[]): T[];
484+
>bar : <T>(f: () => T[]) => T[]
485+
>f : () => T[]
486+
487+
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
488+
>x : Foo[]
489+
>bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]) : any
490+
>bar : <T>(f: () => T[]) => T[]
491+
>() => !!true ? [{ state: State.A }] : [{ state: State.B }] : () => { state: State.A; }[] | { state: State.B; }[]
492+
>!!true ? [{ state: State.A }] : [{ state: State.B }] : { state: State; }[]
493+
>!!true : true
494+
>!true : false
495+
>true : true
496+
>[{ state: State.A }] : { state: State; }[]
497+
>{ state: State.A } : { state: State; }
498+
>state : State
499+
>State.A : State.A
500+
>State : typeof State
501+
>A : State.A
502+
>[{ state: State.B }] : { state: State; }[]
503+
>{ state: State.B } : { state: State; }
504+
>state : State
505+
>State.B : State.B
506+
>State : typeof State
507+
>B : State.B
508+

0 commit comments

Comments
 (0)