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
interfaceNullableProps{nullableProp?: string}typeRequiredProps=Required<NullableProps>declarefunctionwithRequiredProps(requiredProps: RequiredProps): any;functionwithNullableProps(props: NullableProps){if(!props.nullableProp)return;/** this is correct */typeProperlyTypeNarrowedToBeNonNullable=typeofprops.nullableProp/** but this is incorrect */typeIncorrectlyStillNullableProps=typeofprops;/** * Argument of type 'NullableProps' is not assignable to parameter of type 'Required<NullableProps>'. * Types of property 'someNullableProp' are incompatible. * Type 'string | undefined' is not assignable to type 'string'. * Type 'undefined' is not assignable to type 'string'.(2345) */withRequiredProps(props)}
🙁 Actual behavior
the line
if(!props.nullableProp)return;
does not narrow props to be { nullableProp: NonNullable }
🙂 Expected behavior
the line
if(!props.nullableProp)return;
should narrow props to be { nullableProp: NonNullable }
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
interface optional properties props nullable nonnullable non-nullable control flow analysis type narrow
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
the line
does not narrow
props
to be{ nullableProp: NonNullable }
🙂 Expected behavior
the line
should narrow
props
to be{ nullableProp: NonNullable }
The text was updated successfully, but these errors were encountered: