Open
Description
Type description + examples
A type that simplify a union. When merging 2 of more unions TS hide the underline types.
use case:
type U1 = 5 | ['b'] | symbol
type U2 = null | '2' | {foo: 'bar'}
type U3 = U1 | U2
// ^? U3 = U1 | U2
type U4 = SimplifyUnion<U3>
// ^? U4 = symbol | 5 | "2" | ["b"] | {foo: "bar"} | null
Type source
type SimplifyUnion<T> = {[K in T as string]: K}[string]
Search existing types and issues first
- I tried my best to look for it