Skip to content

OmitUnion

Returns a subset of a union without specified components.

Params

NameTypeDescription
inputanyThe union to omit from.
to_omitanyThe 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
inputanyThe union to pick from.
to_pickanyThe 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
inputanyThe 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
inputanyThe union to clean.

Example

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

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