OmitTableByKeys
Returns a subset of a table without properties whose keys contain the specified components.
Params
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to omit from. |
to_omit | any | The values of the properties to omit. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to omit from. |
to_omit | any | The values of the properties to omit. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to pick from. |
to_pick | any | The keys of the properties to pick. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to pick from. |
to_pick | any | The values of the properties to pick. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to flatten. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to clean. |
Example
type Result = TableClean<{ name: string | string, salary: number }>
-- type Result = { name: string, salary: number }
Partial
Makes every property in a table optional.
Params
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make partial. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make deeply partial. |
Example
type Result = DeepPartial<{ hello: "world", foo: { bar: "baz" } }>
-- type Result = { foo: { bar: "baz"? }?, hello: "world"? }
Required
Makes every property in a table required.
Params
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make required. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make deeply required. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make read only. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make deeply read only. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make readable and writable. |
Example
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
Name | Type | Description |
---|---|---|
input | { [any]: type } | The table to make deeply readable and writable. |
Example
type Result = DeepReadWrite<{ read hello: "world", foo: { read bar: "baz" } }>
-- type Result = { foo: { bar: "baz" }, hello: "world" }