Accept new baselines
This commit is contained in:
parent
2b36fdd08b
commit
c3ef035b02
4 changed files with 199 additions and 0 deletions
|
@ -200,4 +200,23 @@ tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts(180,26): error TS23
|
|||
!!! error TS2322: Types of property 'state' are incompatible.
|
||||
!!! error TS2322: Type 'State.B' is not assignable to type 'State.A'.
|
||||
!!! related TS6502 tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts:179:28: The expected type comes from the return type of this signature.
|
||||
|
||||
// Repros from #31443
|
||||
|
||||
enum Enum { A, B }
|
||||
|
||||
class ClassWithConvert<T> {
|
||||
constructor(val: T) { }
|
||||
convert(converter: { to: (v: T) => T; }) { }
|
||||
}
|
||||
|
||||
function fn<T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) { }
|
||||
fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A));
|
||||
|
||||
type Func<T> = (x: T) => T;
|
||||
|
||||
declare function makeFoo<T>(x: T): Func<T>;
|
||||
declare function baz<U>(x: Func<U>, y: Func<U>): void;
|
||||
|
||||
baz(makeFoo(Enum.A), makeFoo(Enum.A));
|
||||
|
|
@ -179,6 +179,25 @@ enum State { A, B }
|
|||
type Foo = { state: State }
|
||||
declare function bar<T>(f: () => T[]): T[];
|
||||
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
|
||||
// Repros from #31443
|
||||
|
||||
enum Enum { A, B }
|
||||
|
||||
class ClassWithConvert<T> {
|
||||
constructor(val: T) { }
|
||||
convert(converter: { to: (v: T) => T; }) { }
|
||||
}
|
||||
|
||||
function fn<T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) { }
|
||||
fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A));
|
||||
|
||||
type Func<T> = (x: T) => T;
|
||||
|
||||
declare function makeFoo<T>(x: T): Func<T>;
|
||||
declare function baz<U>(x: Func<U>, y: Func<U>): void;
|
||||
|
||||
baz(makeFoo(Enum.A), makeFoo(Enum.A));
|
||||
|
||||
|
||||
//// [inferFromGenericFunctionReturnTypes3.js]
|
||||
|
@ -278,6 +297,19 @@ var State;
|
|||
State[State["B"] = 1] = "B";
|
||||
})(State || (State = {}));
|
||||
let x = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
|
||||
// Repros from #31443
|
||||
var Enum;
|
||||
(function (Enum) {
|
||||
Enum[Enum["A"] = 0] = "A";
|
||||
Enum[Enum["B"] = 1] = "B";
|
||||
})(Enum || (Enum = {}));
|
||||
class ClassWithConvert {
|
||||
constructor(val) { }
|
||||
convert(converter) { }
|
||||
}
|
||||
function fn(arg, f) { }
|
||||
fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A));
|
||||
baz(makeFoo(Enum.A), makeFoo(Enum.A));
|
||||
|
||||
|
||||
//// [inferFromGenericFunctionReturnTypes3.d.ts]
|
||||
|
|
|
@ -459,3 +459,84 @@ let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]);
|
|||
>State : Symbol(State, Decl(inferFromGenericFunctionReturnTypes3.ts, 174, 56))
|
||||
>B : Symbol(State.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 176, 15))
|
||||
|
||||
// Repros from #31443
|
||||
|
||||
enum Enum { A, B }
|
||||
>Enum : Symbol(Enum, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 79))
|
||||
>A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>B : Symbol(Enum.B, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 14))
|
||||
|
||||
class ClassWithConvert<T> {
|
||||
>ClassWithConvert : Symbol(ClassWithConvert, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 18))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 185, 23))
|
||||
|
||||
constructor(val: T) { }
|
||||
>val : Symbol(val, Decl(inferFromGenericFunctionReturnTypes3.ts, 186, 14))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 185, 23))
|
||||
|
||||
convert(converter: { to: (v: T) => T; }) { }
|
||||
>convert : Symbol(ClassWithConvert.convert, Decl(inferFromGenericFunctionReturnTypes3.ts, 186, 25))
|
||||
>converter : Symbol(converter, Decl(inferFromGenericFunctionReturnTypes3.ts, 187, 10))
|
||||
>to : Symbol(to, Decl(inferFromGenericFunctionReturnTypes3.ts, 187, 22))
|
||||
>v : Symbol(v, Decl(inferFromGenericFunctionReturnTypes3.ts, 187, 28))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 185, 23))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 185, 23))
|
||||
}
|
||||
|
||||
function fn<T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) { }
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes3.ts, 188, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 190, 12))
|
||||
>arg : Symbol(arg, Decl(inferFromGenericFunctionReturnTypes3.ts, 190, 15))
|
||||
>ClassWithConvert : Symbol(ClassWithConvert, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 18))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 190, 12))
|
||||
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes3.ts, 190, 40))
|
||||
>ClassWithConvert : Symbol(ClassWithConvert, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 18))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 190, 12))
|
||||
|
||||
fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A));
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes3.ts, 188, 1))
|
||||
>ClassWithConvert : Symbol(ClassWithConvert, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 18))
|
||||
>Enum.A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>Enum : Symbol(Enum, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 79))
|
||||
>A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>ClassWithConvert : Symbol(ClassWithConvert, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 18))
|
||||
>Enum.A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>Enum : Symbol(Enum, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 79))
|
||||
>A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
|
||||
type Func<T> = (x: T) => T;
|
||||
>Func : Symbol(Func, Decl(inferFromGenericFunctionReturnTypes3.ts, 191, 69))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 10))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 16))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 10))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 10))
|
||||
|
||||
declare function makeFoo<T>(x: T): Func<T>;
|
||||
>makeFoo : Symbol(makeFoo, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 27))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 195, 25))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 195, 28))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 195, 25))
|
||||
>Func : Symbol(Func, Decl(inferFromGenericFunctionReturnTypes3.ts, 191, 69))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes3.ts, 195, 25))
|
||||
|
||||
declare function baz<U>(x: Func<U>, y: Func<U>): void;
|
||||
>baz : Symbol(baz, Decl(inferFromGenericFunctionReturnTypes3.ts, 195, 43))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 196, 21))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes3.ts, 196, 24))
|
||||
>Func : Symbol(Func, Decl(inferFromGenericFunctionReturnTypes3.ts, 191, 69))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 196, 21))
|
||||
>y : Symbol(y, Decl(inferFromGenericFunctionReturnTypes3.ts, 196, 35))
|
||||
>Func : Symbol(Func, Decl(inferFromGenericFunctionReturnTypes3.ts, 191, 69))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes3.ts, 196, 21))
|
||||
|
||||
baz(makeFoo(Enum.A), makeFoo(Enum.A));
|
||||
>baz : Symbol(baz, Decl(inferFromGenericFunctionReturnTypes3.ts, 195, 43))
|
||||
>makeFoo : Symbol(makeFoo, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 27))
|
||||
>Enum.A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>Enum : Symbol(Enum, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 79))
|
||||
>A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>makeFoo : Symbol(makeFoo, Decl(inferFromGenericFunctionReturnTypes3.ts, 193, 27))
|
||||
>Enum.A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
>Enum : Symbol(Enum, Decl(inferFromGenericFunctionReturnTypes3.ts, 179, 79))
|
||||
>A : Symbol(Enum.A, Decl(inferFromGenericFunctionReturnTypes3.ts, 183, 11))
|
||||
|
||||
|
|
|
@ -506,3 +506,70 @@ let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]);
|
|||
>State : typeof State
|
||||
>B : State.B
|
||||
|
||||
// Repros from #31443
|
||||
|
||||
enum Enum { A, B }
|
||||
>Enum : Enum
|
||||
>A : Enum.A
|
||||
>B : Enum.B
|
||||
|
||||
class ClassWithConvert<T> {
|
||||
>ClassWithConvert : ClassWithConvert<T>
|
||||
|
||||
constructor(val: T) { }
|
||||
>val : T
|
||||
|
||||
convert(converter: { to: (v: T) => T; }) { }
|
||||
>convert : (converter: { to: (v: T) => T; }) => void
|
||||
>converter : { to: (v: T) => T; }
|
||||
>to : (v: T) => T
|
||||
>v : T
|
||||
}
|
||||
|
||||
function fn<T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) { }
|
||||
>fn : <T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) => void
|
||||
>arg : ClassWithConvert<T>
|
||||
>f : () => ClassWithConvert<T>
|
||||
|
||||
fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A));
|
||||
>fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A)) : void
|
||||
>fn : <T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) => void
|
||||
>new ClassWithConvert(Enum.A) : ClassWithConvert<Enum>
|
||||
>ClassWithConvert : typeof ClassWithConvert
|
||||
>Enum.A : Enum.A
|
||||
>Enum : typeof Enum
|
||||
>A : Enum.A
|
||||
>() => new ClassWithConvert(Enum.A) : () => ClassWithConvert<Enum>
|
||||
>new ClassWithConvert(Enum.A) : ClassWithConvert<Enum>
|
||||
>ClassWithConvert : typeof ClassWithConvert
|
||||
>Enum.A : Enum.A
|
||||
>Enum : typeof Enum
|
||||
>A : Enum.A
|
||||
|
||||
type Func<T> = (x: T) => T;
|
||||
>Func : Func<T>
|
||||
>x : T
|
||||
|
||||
declare function makeFoo<T>(x: T): Func<T>;
|
||||
>makeFoo : <T>(x: T) => Func<T>
|
||||
>x : T
|
||||
|
||||
declare function baz<U>(x: Func<U>, y: Func<U>): void;
|
||||
>baz : <U>(x: Func<U>, y: Func<U>) => void
|
||||
>x : Func<U>
|
||||
>y : Func<U>
|
||||
|
||||
baz(makeFoo(Enum.A), makeFoo(Enum.A));
|
||||
>baz(makeFoo(Enum.A), makeFoo(Enum.A)) : void
|
||||
>baz : <U>(x: Func<U>, y: Func<U>) => void
|
||||
>makeFoo(Enum.A) : Func<Enum>
|
||||
>makeFoo : <T>(x: T) => Func<T>
|
||||
>Enum.A : Enum.A
|
||||
>Enum : typeof Enum
|
||||
>A : Enum.A
|
||||
>makeFoo(Enum.A) : Func<Enum>
|
||||
>makeFoo : <T>(x: T) => Func<T>
|
||||
>Enum.A : Enum.A
|
||||
>Enum : typeof Enum
|
||||
>A : Enum.A
|
||||
|
||||
|
|
Loading…
Reference in a new issue