Closed
Description
Propagated Inference for Uninstantiated (Free) Type Parameters (#9366)
Given #16072, we can now make more powerful inferences given contextual types on the return type of a call.
However, given the following:
function compose<A, B, C>(
f: (x: A) => B,
g: (y: B) => C,
): (x: A) => C;
compose(
x => [x],
y => ({ foo: x })
)
- Right now we just fall back to the instantiations of
A = {}
,B = {}
,C = {}
. - This is unfortunate because in this scenario, there is no real constraint on the types of the parameters.
- Ideally, because these are universal functions, the return type should still be a generic function: `(x: A) => { foo: A }
- We've managed to get this working.
- This pretty much always works well if your function arguments are less specific in their constraints than those of the invoked expression.
- Doesn't work for certain cases when the opposite is true.
- @gcnew has an implementation that can handle some of these cases.
- Will investigate on a combined approach.
@mhegazy may have notes on weak types (#16047) and synthesized namespace records (#16093)