Constructs a type that can be either a value or nothing.
This type is useful for representing optional values, similar to TypeScript's
built-in optional properties, but as an explicit union type. It's particularly
helpful when working with the Maybe type from folklore.
Examples
Example 1
// Function parameter that accepts a value or nothingfunctiongreet(name: Nullable<string>): string {
return name !=null ? `Hello, ${name}!` : 'Hello, stranger!'
}
greet('Alice') // "Hello, Alice!"greet(null) // "Hello, stranger!"greet(undefined) // "Hello, stranger!"