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
Generic parameter types are incorrectly inferred as { } #26809
Seems there is not enough context for TS to infer R in some2, since you are not passing any argument with type R. You can fix this by explicitly telling TypeScript to infer R from the interface:
interfaceA<R>{a(): R}declarefunctionsome2<DextendsA<any>>(a: D): DextendsA<infer R> ? R : any;letout2=some2({a(){return'asd'}})// out2 is string!
Activity
AlCalzone commentedon Aug 31, 2018
Seems there is not enough context for TS to infer
Rinsome2, since you are not passing any argument with typeR. You can fix this by explicitly telling TypeScript to inferRfrom the interface:2A5F commentedon Aug 31, 2018
But why would it be
{}instead of an errorAlCalzone commentedon Aug 31, 2018
As far as I understand,
{}is the default when inference fails. This keeps the type-checking enabled - as opposed toany, which doesn't.