Skip to content

OmitTableByKeys

Returns a subset of a table without properties whose keys contain the specified components.

Params

NameTypeDescription
input{ [any]: type }The table to omit from.
to_omitanyThe values of the properties to omit.

Example

luau
type Result = OmitTableByKeys<{ hello: string, foo: "bar", bar: number }, "hello" | "foo">

-- type Result = type Result = { bar: number }

OmitTableByValues

Returns a subset of a table without properties whose values contain the specified components.

Params

NameTypeDescription
input{ [any]: type }The table to omit from.
to_omitanyThe values of the properties to omit.

Example

luau
type Result = OmitTableByValues<{ hello: string, foo: "bar", bar: number }, "bar" | string>

-- type Result = type Result = { bar: number }

PickTableByKeys

Returns a subset of a table with only properties whose keys contain the specified components.

Params

NameTypeDescription
input{ [any]: type }The table to pick from.
to_pickanyThe keys of the properties to pick.

Example

luau
type Result = PickTableByKeys<{ hello: string, foo: "bar", bar: number }, "hello" | "foo">

-- type Result = type Result = { foo: "bar", hello: string }

PickTableByValues

Returns a subset of a table with only properties whose values contain the specified components.

Params

NameTypeDescription
input{ [any]: type }The table to pick from.
to_pickanyThe values of the properties to pick.

Example

luau
type Result = PickTableByValues<{ hello: string, foo: "bar", bar: number }, "bar" | string>

-- type Result = type Result = { foo: "bar", hello: string }

FlattenTable

Combines an intersection of tables into one consolidated table whilst preserving semantics.

Params

NameTypeDescription
input{ [any]: type }The table to flatten.

Example

luau
type Result = FlattenTable<
    { name: string, salary: number } &
    { kind: "employee" }
>

--[[
    type Result = {
        name: string,
        salary: number,
        kind: "employee"
    }
]]

CleanTable

Removes duplicate types from union and intersection keys and values inside the specified table.

Params

NameTypeDescription
input{ [any]: type }The table to clean.

Example

luau
type Result = TableClean<{ name: string | string, salary: number }>

-- type Result = { name: string, salary: number }

Partial

Makes every property in a table optional.

Params

NameTypeDescription
input{ [any]: type }The table to make partial.

Example

luau
type Result = Partial<{ hello: "world", foo: "bar" }>

-- type Result = { foo: "bar"?, hello: "world"? }

DeepPartial

Makes every property (including nested ones) in a table optional.

Params

NameTypeDescription
input{ [any]: type }The table to make deeply partial.

Example

luau
type Result = DeepPartial<{ hello: "world", foo: { bar: "baz" } }>

-- type Result = { foo: { bar: "baz"? }?, hello: "world"? }

Required

Makes every property in a table required.

Params

NameTypeDescription
input{ [any]: type }The table to make required.

Example

luau
type Result = Required<{ hello: "world"?, foo: "bar"? }>

-- type Result = { foo: "bar", hello: "world" }

DeepRequired

Makes every property (including nested ones) in a table required.

Params

NameTypeDescription
input{ [any]: type }The table to make deeply required.

Example

luau
type Result = DeepRequired<{ hello: { lol: "kek"? }?, foo: "bar"? }>

-- type Result = { foo: { lol: "kek" }, hello: "world" }

ReadOnly

Makes every property in a table read only.

Params

NameTypeDescription
input{ [any]: type }The table to make read only.

Example

luau
type Result = ReadOnly<{ hello: "world", foo: "bar" }>

-- type Result = { read foo: "bar", read hello: "world" }

DeepReadOnly

Makes every property (including nested ones) in a table read only.

Params

NameTypeDescription
input{ [any]: type }The table to make deeply read only.

Example

luau
type Result = DeepReadOnly<{ hello: "world", foo: { bar: "baz" } }>

-- type Result = { read foo: { read bar: "baz" }, read hello: "world" }

ReadWrite

Makes every property in a table readable and writable.

Params

NameTypeDescription
input{ [any]: type }The table to make readable and writable.

Example

luau
type Result = ReadWrite<{ read hello: "world", foo: "bar" }>

-- type Result = { foo: "bar", hello: "world" }

DeepReadWrite

Makes every property (including nested ones) in a table readable and writable.

Params

NameTypeDescription
input{ [any]: type }The table to make deeply readable and writable.

Example

luau
type Result = DeepReadWrite<{ read hello: "world", foo: { read bar: "baz" } }>

-- type Result = { foo: { bar: "baz" }, hello: "world" }