const doSomething = <
B extends Bar<F>,
F extends Foo,
>(
FooConstructor: { new(...args : any[]): F; },
BarConstructor: { new(...args : any[]): B; },
): B => {
return new BarConstructor({});
}
const mything = doSomething(CustomFoo, CustomBar);
Unfortunately the type of mything
is Bar<CustomFoo>
whereas I require it to be CustomBar<CustomFoo>
.
I would have expected TypeScript to infer the return type.
1