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
In this example, in the first function call narrows opts down to { x: string } based on the first parameter opts1 only. However, as opts is used for both opts1 and opts2, TypeScript should consider both parameters when narrowing a type for opts.
As seen in the second call, a solution does exist in which the constraint is met and neither parameter errors.
In the meantime, this can either be completely avoided by a different solution, or the generic type can be passed explicitly.
The text was updated successfully, but these errors were encountered:
Suggestion
π Search Terms
Inference, Function, Generic, Parameters
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
When inferring type parameters of a function based on parameters, TypeScript should consider all parameters that use the generic type.
Workbench Repro
In this example, in the first function call narrows
opts
down to{ x: string }
based on the first parameteropts1
only. However, asopts
is used for bothopts1
andopts2
, TypeScript should consider both parameters when narrowing a type foropts
.As seen in the second call, a solution does exist in which the constraint is met and neither parameter errors.
In the meantime, this can either be completely avoided by a different solution, or the generic type can be passed explicitly.
The text was updated successfully, but these errors were encountered: