You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change in behavior around keyof any inference #29765
Looks like this is an effect of #29478. Previously we'd make no inferences from the return type in the second example, but now we infer from { foo: any; bar: any } to Pick<T, K>. This produces an inference for K, but not for T because Pick<T, K> isn't a homomorphic mapped type (it's partially homomorphic in that it only maps a subset of the properties). Because we have no candidates for T, we end up with an inference of {} from the return type, which then causes us to reduce our inference for K to never. We then proceed with this rather useless contextual type which ends up making matters worse rather than better.
Looks like we need to do better when inferring to Pick<T, K>. I will see what we can do.
Activity
ahejlsberg commentedon Feb 6, 2019
Looks like this is an effect of #29478. Previously we'd make no inferences from the return type in the second example, but now we infer from
{ foo: any; bar: any }toPick<T, K>. This produces an inference forK, but not forTbecausePick<T, K>isn't a homomorphic mapped type (it's partially homomorphic in that it only maps a subset of the properties). Because we have no candidates forT, we end up with an inference of{}from the return type, which then causes us to reduce our inference forKtonever. We then proceed with this rather useless contextual type which ends up making matters worse rather than better.Looks like we need to do better when inferring to
Pick<T, K>. I will see what we can do.