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
TypeScript doesn't assume the value type in a ternary operator when it has been assigned before if the value is an object keyΒ #50356
Narrowing through indirect references occurs only when the conditional expression or discriminant property access is declared in a const variable declaration with no type annotation, and the reference being narrowed is a const variable, a readonly property, or a parameter for which there are no assignments in the function body.
So you have to mark the property value readonly to make it work:
Activity
whzx5byb commentedon Aug 18, 2022
From #44730:
So you have to mark the property
valuereadonly to make it work:type Props = { - value: string | Array<string> | [] | null; + readonly value: string | Array<string> | [] | null; };