Skip to content

Omit

Returns a subset of a type without specified components / properties.

Params

NameTypeDescription
inputanyThe type to omit from.
to_omitanyThe components / properties to omit.

Example

luau
type Result = Omit<
    "hello" | "world" | "foo" | "bar",
    "world" | "bar"
>

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

Pick

Returns a subset of a type with only specified components / properties.

Params

NameTypeDescription
inputanyThe type to pick from.
to_pickanyThe components / properties to pick.

Example

luau
type Result = Pick<
    "hello" & "world" & "foo" & "bar",
    "world" | "bar"
>

-- type Result = "bar" & "world"

Flatten

Combines a nested union or intersection into one union / intersection. Combines an intersection of tables into one consolidated table whilst preserving semantics.

Params

NameTypeDescription
inputanyThe type to flatten.

Example

luau
type Result = Flatten<({ hello: "world" } & ({ foo: "bar" } | { lol: "kek" }))>

--[[
    type Result = {
        foo: "bar",
        hello: "world"
    } | {
        hello: "world",
        lol: "kek"
    }
]]

Clean

Removes duplicate components / properties from a type.

Params

NameTypeDescription
inputanyThe type to clean.

Example

luau
type Result = Clean<{
    age: number | number,
    [boolean]: boolean | boolean
}>

--[[
    type Result = {
        [boolean]: boolean,
        age: number
    }
]]