Use the NonNullable built-in type:
type NonNullable<T> = Exclude<T, null | undefined>; // Remove null and undefined from T
See TypeScript: Documentation – Utility Types
Use the NonNullable built-in type:
type NonNullable<T> = Exclude<T, null | undefined>; // Remove null and undefined from T
See TypeScript: Documentation – Utility Types