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
functiontest<Textendsstring|null>(input: T): NonNullable<T>{if(!input){// this should narrow `input` to `T extends string`thrownewError();}returninput;// type error}
π Actual behavior
Type error
Type 'T' is not assignable to type 'NonNullable<T>'.
Type 'string | null' is not assignable to type 'NonNullable<T>'.
Type 'null' is not assignable to type 'NonNullable<T>'.
π Expected behavior
TypeScript should know I've narrowed the generic type to satisfied the NonNullable type.
I came across #43183 which I was expecting to also address this scenario.
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Type error
π Expected behavior
TypeScript should know I've narrowed the generic type to satisfied the
NonNullable
type.I came across #43183 which I was expecting to also address this scenario.
The text was updated successfully, but these errors were encountered: