Description
Is your feature request related to a problem? Please describe.
So there is the Maybe
type already which says the value can be null
which actually is more like Nullable
if you ask me. Anyway, so the value may be null
but if it is optional it also does not need to exist at all, so you either have ?
or | undefined
added to the Maybe
which could be shorter with adding an extra type for that.
Describe the solution you'd like
So additionally to the Maybe
utility type lets have something like Nullable
(😁 ) which is something like type Nullable<T> = Maybe<T> | undefined = T | null | undefined
Or if you want some other intermediate type maybe something like
type Nothing = null | undefined
type Nullable<T> = T | Nothing
Additional context
Let's have a look at validation lib Zod for a moment. You have the option to use .nullable()
and chain .optional()
as well, but there is a short form for this which is called .nullish()