Skip to content

OmitUnion ​

Returns a subset of a union without specified components.

Params ​

NameTypeDescription
inputtypeThe union to omit from.
to_omittypeThe components to omit.

Example ​

luau
type Result = OmitUnion<
    "hello" | string | "world",
    "world"
>

-- type Result = "hello" | string

PickUnion ​

Returns a subset of a union with only specified components.

Params ​

NameTypeDescription
inputtypeThe union to pick from.
to_picktypeThe components to pick.

Example ​

luau
type Result = PickUnion<
    "hello" | string | "world",
    "world"
>

-- type Result = "world"

FlattenUnion ​

Recursively combines nested unions into one union.

Params ​

NameTypeDescription
inputtypeThe union to flatten.

Example ​

luau
type Result = FlattenUnion<"foo" | ("hello" | ("world" | "lol"))>

-- type Result = "foo" | "hello" | "lol" | "world"

CleanUnion ​

Removes duplicate types from a union.

Params ​

NameTypeDescription
inputtypeThe union to clean.

Example ​

luau
type Result = CleanUnion<"hello" | string | "world" | string | "foo" | "hello">

-- type Result = "foo" | "hello" | "world" | string