Skip to content

Commit 2b36fdd

Browse files
committed
Add regression tests
1 parent b75a90e commit 2b36fdd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/cases/compiler/inferFromGenericFunctionReturnTypes3.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,22 @@ enum State { A, B }
182182
type Foo = { state: State }
183183
declare function bar<T>(f: () => T[]): T[];
184184
let x: Foo[] = bar(() => !!true ? [{ state: State.A }] : [{ state: State.B }]); // Error
185+
186+
// Repros from #31443
187+
188+
enum Enum { A, B }
189+
190+
class ClassWithConvert<T> {
191+
constructor(val: T) { }
192+
convert(converter: { to: (v: T) => T; }) { }
193+
}
194+
195+
function fn<T>(arg: ClassWithConvert<T>, f: () => ClassWithConvert<T>) { }
196+
fn(new ClassWithConvert(Enum.A), () => new ClassWithConvert(Enum.A));
197+
198+
type Func<T> = (x: T) => T;
199+
200+
declare function makeFoo<T>(x: T): Func<T>;
201+
declare function baz<U>(x: Func<U>, y: Func<U>): void;
202+
203+
baz(makeFoo(Enum.A), makeFoo(Enum.A));

0 commit comments

Comments
 (0)