ts-toolbelt

  • Version 9.6.0
  • Published
  • 248 kB
  • No dependencies
  • Apache-2.0 license

Install

npm i ts-toolbelt
yarn add ts-toolbelt
pnpm add ts-toolbelt

Overview

TypeScript's largest utility library

Index

Namespaces

Namespaces

namespace A

module 'out/Any/_api.d.ts' {}

type At

type At<A extends any, K extends Key> = A extends List
? number extends A['length']
? K extends number | `${number}`
? A[never] | undefined
: undefined
: K extends keyof A
? A[K]
: undefined
: unknown extends A
? unknown
: K extends keyof A
? A[K]
: undefined;
  • Get in O the type of a field of key K

    Parameter O

    to extract from

    Parameter K

    to extract at

    Returns

    [[Any]]

    Example 1

    import {O} from 'ts-toolbelt'
    type User = {
    info: {
    name: string
    age: number
    payment: {}
    }
    id: number
    }
    type test0 = O.At<User, 'id'> // number

type Await

type Await<P extends any> = P extends Promise<infer A> ? A : P;
  • Get the result type of a Promise

    Parameter P

    A promise

    Returns

    [[Any]]

    Example 1

    import {C} from 'ts-toolbelt'
    const promise = new Promise<string>((res, rej) => res('x'))
    type test0 = C.Await<typeof promise> // string
    type test1 = C.Await<Promise<number>> // number

type Cast

type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
  • Ask TS to re-check that A1 extends A2. And if it fails, A2 will be enforced anyway. Can also be used to add constraints on parameters.

    Parameter A1

    to check against

    Parameter A2

    to cast to

    Returns

    A1 | A2

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Cast<'42', string> // '42'
    type test1 = A.Cast<'42', number> // number

type Compute

type Compute<A extends any, depth extends Depth = 'deep'> = {
flat: ComputeFlat<A>;
deep: ComputeDeep<A>;
}[depth];
  • Force TS to load a type that has not been computed (to resolve composed types that TS haven't fully resolved, for display purposes mostly).

    Parameter A

    to compute

    Returns

    A

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Compute<{x: 'x'} & {y: 'y'}> // {x: 'x', y: 'y'}

type Contains

type Contains<A1 extends any, A2 extends any> = Extends<A1, A2> extends 1 ? 1 : 0;
  • Check whether A1 is part of A2 or not. It works like [[Extends]] but [[Boolean]] results are narrowed to [[False]].

    Parameter A1

    Parameter A2

    Returns

    [[Boolean]]

    Example 1

    type test0 = A.Contains<'a' | 'b', 'b'> // False
    type test1 = A.Contains<'a', 'a' | 'b'> // True
    type test2 = A.Contains<{a: string}, {a: string, b: number}> // False
    type test3 = A.Contains<{a: string, b: number}, {a: string}> // True
    type test4 = A.Contains<never, never> // False
    /// Nothing cannot contain nothing, use `A.Equals`

type Equals

type Equals<A1 extends any, A2 extends any> = (<A>() => A extends A2
? 1
: 0) extends <A>() => A extends A1 ? 1 : 0
? 1
: 0;
  • Check whether A1 is equal to A2 or not.

    Parameter A1

    Parameter A2

    Returns

    [[Boolean]]

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Equals<42 | 0, 42 | 0> // true
    type test1 = A.Equals<{a: string}, {b: string}> // false
    type test3 = A.Equals<{a: string}, {readonly a: string}> // false

type Extends

type Extends<A1 extends any, A2 extends any> = [A1] extends [never]
? 0
: A1 extends A2
? 1
: 0;
  • Check whether A1 is part of A2 or not. The difference with extends is that it forces a [[Boolean]] return.

    Parameter A1

    Parameter A2

    Returns

    [[Boolean]]

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
    type test1 = A.Extends<'a', 'a' | 'b'> // True
    type test2 = A.Extends<{a: string}, {a: any}> // True
    type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
    type test4 = A.Extends<never, never> // False
    /// Nothing cannot extend nothing, use `A.Equals`

type Is

type Is<A extends any, A1 extends any, match extends Match = 'default'> = {
default: Extends<A, A1>;
'contains->': Contains<A, A1>;
'extends->': Extends<A, A1>;
'<-contains': Contains<A1, A>;
'<-extends': Extends<A1, A>;
equals: Equals<A1, A>;
}[match];
  • Check whether A is similar to A1 or not. In other words, it is a compact type that bundles [[Equals]], [[Extends]], [[Contains]], comparison types.

    Parameter A

    to be compared

    Parameter A1

    to compare to

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Is<'a', 'a' | 'b', 'extends->'> // True
    type test1 = A.Is<'a' | 'b', 'a', 'extends->'> // Boolean
    type test2 = A.Is<'a', 'a' | 'b', '<-extends'> // Boolean
    type test3 = A.Is<'a' | 'b', 'a', '<-extends'> // True
    type test4 = A.Is<'a', 'a' | 'b', 'contains->'> // True
    type test5 = A.Is<'a' | 'b', 'a', 'contains->'> // False
    type test6 = A.Is<'a', 'a' | 'b', '<-contains'> // False
    type test7 = A.Is<'a' | 'b', 'a', '<-contains'> // True
    type test8 = A.Is<'a', 'a' | 'b', 'equals'> // False
    type test9 = A.Is<'b' |'a', 'a' | 'b', 'equals'> // True

type Key

type Key = string | number | symbol;
  • Describes index keys for any type

type Keys

type Keys<A extends any> = A extends List
? Exclude<keyof A, keyof any[]> | number
: keyof A;
  • Get the keys of A

    Parameter A

    Returns

    [[Key]]

    Example 1

    ```ts ```

type KnownKeys

type KnownKeys<O extends object> = {
[K in keyof O]: string extends K ? never : number extends K ? never : K;
} extends {
[K in keyof O]: infer U;
}
? U & Keys<O>
: never;
  • Get the known keys of an [[Object]]

    Parameter O

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Promise

type Promise<A extends any> = globalThis.Promise<
A extends globalThis.Promise<infer X> ? X : A
>;
  • Create an asynchronous operation like the original Promise type but this one prevents promises to be wrapped within more promises (not possible).

    Parameter A

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Promise<Promise<number>> // Promise<number>
    type test1 = Promise<Promise<number>> // Promise<Promise<number>>

type Try

type Try<A1 extends any, A2 extends any, Catch = never> = A1 extends A2 ? A1 : Catch;
  • Similar to [[Cast]] but with a custom fallback Catch. If it fails, it will enforce Catch instead of A2.

    Parameter A1

    to check against

    Parameter A2

    to try/test with

    Parameter Catch

    to fallback to if the test failed

    Returns

    A1 | Catch

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Try<'42', string> // '42'
    type test1 = A.Try<'42', number> // never
    type test1 = A.Try<'42', number, 'tried'> // 'tried'

type Type

type Type<A extends any, Id extends Key> = {
[id]: Id;
} & A;
  • Create your own opaque sub-type from a type A

    Parameter A

    to be personalized

    Parameter Id

    to name the sub-type

    Returns

    A new type Type<A, Id>

    Example 1

    import {A} from 'ts-toolbelt'
    type EUR = A.Type<number, 'eur'>
    type USD = A.Type<number, 'usd'>
    let eurWallet = 10 as EUR
    let usdWallet = 15 as USD
    eurWallet = usdWallet // error

type x

type x = typeof _ & {};
  • A placeholder that is used in various ways

namespace Any

module 'out/Any/_api.d.ts' {}

type At

type At<A extends any, K extends Key> = A extends List
? number extends A['length']
? K extends number | `${number}`
? A[never] | undefined
: undefined
: K extends keyof A
? A[K]
: undefined
: unknown extends A
? unknown
: K extends keyof A
? A[K]
: undefined;
  • Get in O the type of a field of key K

    Parameter O

    to extract from

    Parameter K

    to extract at

    Returns

    [[Any]]

    Example 1

    import {O} from 'ts-toolbelt'
    type User = {
    info: {
    name: string
    age: number
    payment: {}
    }
    id: number
    }
    type test0 = O.At<User, 'id'> // number

type Await

type Await<P extends any> = P extends Promise<infer A> ? A : P;
  • Get the result type of a Promise

    Parameter P

    A promise

    Returns

    [[Any]]

    Example 1

    import {C} from 'ts-toolbelt'
    const promise = new Promise<string>((res, rej) => res('x'))
    type test0 = C.Await<typeof promise> // string
    type test1 = C.Await<Promise<number>> // number

type Cast

type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
  • Ask TS to re-check that A1 extends A2. And if it fails, A2 will be enforced anyway. Can also be used to add constraints on parameters.

    Parameter A1

    to check against

    Parameter A2

    to cast to

    Returns

    A1 | A2

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Cast<'42', string> // '42'
    type test1 = A.Cast<'42', number> // number

type Compute

type Compute<A extends any, depth extends Depth = 'deep'> = {
flat: ComputeFlat<A>;
deep: ComputeDeep<A>;
}[depth];
  • Force TS to load a type that has not been computed (to resolve composed types that TS haven't fully resolved, for display purposes mostly).

    Parameter A

    to compute

    Returns

    A

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Compute<{x: 'x'} & {y: 'y'}> // {x: 'x', y: 'y'}

type Contains

type Contains<A1 extends any, A2 extends any> = Extends<A1, A2> extends 1 ? 1 : 0;
  • Check whether A1 is part of A2 or not. It works like [[Extends]] but [[Boolean]] results are narrowed to [[False]].

    Parameter A1

    Parameter A2

    Returns

    [[Boolean]]

    Example 1

    type test0 = A.Contains<'a' | 'b', 'b'> // False
    type test1 = A.Contains<'a', 'a' | 'b'> // True
    type test2 = A.Contains<{a: string}, {a: string, b: number}> // False
    type test3 = A.Contains<{a: string, b: number}, {a: string}> // True
    type test4 = A.Contains<never, never> // False
    /// Nothing cannot contain nothing, use `A.Equals`

type Equals

type Equals<A1 extends any, A2 extends any> = (<A>() => A extends A2
? 1
: 0) extends <A>() => A extends A1 ? 1 : 0
? 1
: 0;
  • Check whether A1 is equal to A2 or not.

    Parameter A1

    Parameter A2

    Returns

    [[Boolean]]

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Equals<42 | 0, 42 | 0> // true
    type test1 = A.Equals<{a: string}, {b: string}> // false
    type test3 = A.Equals<{a: string}, {readonly a: string}> // false

type Extends

type Extends<A1 extends any, A2 extends any> = [A1] extends [never]
? 0
: A1 extends A2
? 1
: 0;
  • Check whether A1 is part of A2 or not. The difference with extends is that it forces a [[Boolean]] return.

    Parameter A1

    Parameter A2

    Returns

    [[Boolean]]

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
    type test1 = A.Extends<'a', 'a' | 'b'> // True
    type test2 = A.Extends<{a: string}, {a: any}> // True
    type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
    type test4 = A.Extends<never, never> // False
    /// Nothing cannot extend nothing, use `A.Equals`

type Is

type Is<A extends any, A1 extends any, match extends Match = 'default'> = {
default: Extends<A, A1>;
'contains->': Contains<A, A1>;
'extends->': Extends<A, A1>;
'<-contains': Contains<A1, A>;
'<-extends': Extends<A1, A>;
equals: Equals<A1, A>;
}[match];
  • Check whether A is similar to A1 or not. In other words, it is a compact type that bundles [[Equals]], [[Extends]], [[Contains]], comparison types.

    Parameter A

    to be compared

    Parameter A1

    to compare to

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Is<'a', 'a' | 'b', 'extends->'> // True
    type test1 = A.Is<'a' | 'b', 'a', 'extends->'> // Boolean
    type test2 = A.Is<'a', 'a' | 'b', '<-extends'> // Boolean
    type test3 = A.Is<'a' | 'b', 'a', '<-extends'> // True
    type test4 = A.Is<'a', 'a' | 'b', 'contains->'> // True
    type test5 = A.Is<'a' | 'b', 'a', 'contains->'> // False
    type test6 = A.Is<'a', 'a' | 'b', '<-contains'> // False
    type test7 = A.Is<'a' | 'b', 'a', '<-contains'> // True
    type test8 = A.Is<'a', 'a' | 'b', 'equals'> // False
    type test9 = A.Is<'b' |'a', 'a' | 'b', 'equals'> // True

type Key

type Key = string | number | symbol;
  • Describes index keys for any type

type Keys

type Keys<A extends any> = A extends List
? Exclude<keyof A, keyof any[]> | number
: keyof A;
  • Get the keys of A

    Parameter A

    Returns

    [[Key]]

    Example 1

    ```ts ```

type KnownKeys

type KnownKeys<O extends object> = {
[K in keyof O]: string extends K ? never : number extends K ? never : K;
} extends {
[K in keyof O]: infer U;
}
? U & Keys<O>
: never;
  • Get the known keys of an [[Object]]

    Parameter O

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Promise

type Promise<A extends any> = globalThis.Promise<
A extends globalThis.Promise<infer X> ? X : A
>;
  • Create an asynchronous operation like the original Promise type but this one prevents promises to be wrapped within more promises (not possible).

    Parameter A

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Promise<Promise<number>> // Promise<number>
    type test1 = Promise<Promise<number>> // Promise<Promise<number>>

type Try

type Try<A1 extends any, A2 extends any, Catch = never> = A1 extends A2 ? A1 : Catch;
  • Similar to [[Cast]] but with a custom fallback Catch. If it fails, it will enforce Catch instead of A2.

    Parameter A1

    to check against

    Parameter A2

    to try/test with

    Parameter Catch

    to fallback to if the test failed

    Returns

    A1 | Catch

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.Try<'42', string> // '42'
    type test1 = A.Try<'42', number> // never
    type test1 = A.Try<'42', number, 'tried'> // 'tried'

type Type

type Type<A extends any, Id extends Key> = {
[id]: Id;
} & A;
  • Create your own opaque sub-type from a type A

    Parameter A

    to be personalized

    Parameter Id

    to name the sub-type

    Returns

    A new type Type<A, Id>

    Example 1

    import {A} from 'ts-toolbelt'
    type EUR = A.Type<number, 'eur'>
    type USD = A.Type<number, 'usd'>
    let eurWallet = 10 as EUR
    let usdWallet = 15 as USD
    eurWallet = usdWallet // error

type x

type x = typeof _ & {};
  • A placeholder that is used in various ways

namespace B

module 'out/Boolean/_api.d.ts' {}

type And

type And<B1 extends Boolean, B2 extends Boolean> = {
0: {
0: 0;
1: 0;
};
1: {
0: 0;
1: 1;
};
}[B1][B2];
  • Logical && operator (behaves like the JS one)

    Parameter B1

    Left-hand side

    Parameter B2

    Right-hand side

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.And<B.True, B.False> // False
    type test1 = B.And<B.True, B.True> // True
    type test2 = B.And<B.True | B.False, B.True> // Boolean

type Not

type Not<B extends Boolean> = {
0: 1;
1: 0;
}[B];
  • Logical ! operator (behaves like the JS one)

    Parameter B

    to negate

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.Not<B.True> // False
    type test1 = B.Not<B.False> // True

type Or

type Or<B1 extends Boolean, B2 extends Boolean> = {
0: {
0: 0;
1: 1;
};
1: {
0: 1;
1: 1;
};
}[B1][B2];
  • Logical || operator (behaves like the JS one)

    Parameter B1

    Left-hand side

    Parameter B2

    Right-hand side

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.Or<B.True, B.False> // True
    type test1 = B.Or<B.True, B.True> // True
    type test2 = B.Or<B.Boolean, B.False> // Boolean

type Xor

type Xor<B1 extends Boolean, B2 extends Boolean> = {
0: {
0: 0;
1: 1;
};
1: {
0: 1;
1: 0;
};
}[B1][B2];
  • Logical ^ operator (behaves like the JS one)

    Parameter B1

    Left-hand side

    Parameter B2

    Right-hand side

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.Xor<B.True, B.True> // False
    type test1 = B.Xor<B.False, B.True> // True
    type test2 = B.Xor<B.Boolean, B.True> // Boolean

namespace Boolean

module 'out/Boolean/_api.d.ts' {}

type And

type And<B1 extends Boolean, B2 extends Boolean> = {
0: {
0: 0;
1: 0;
};
1: {
0: 0;
1: 1;
};
}[B1][B2];
  • Logical && operator (behaves like the JS one)

    Parameter B1

    Left-hand side

    Parameter B2

    Right-hand side

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.And<B.True, B.False> // False
    type test1 = B.And<B.True, B.True> // True
    type test2 = B.And<B.True | B.False, B.True> // Boolean

type Not

type Not<B extends Boolean> = {
0: 1;
1: 0;
}[B];
  • Logical ! operator (behaves like the JS one)

    Parameter B

    to negate

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.Not<B.True> // False
    type test1 = B.Not<B.False> // True

type Or

type Or<B1 extends Boolean, B2 extends Boolean> = {
0: {
0: 0;
1: 1;
};
1: {
0: 1;
1: 1;
};
}[B1][B2];
  • Logical || operator (behaves like the JS one)

    Parameter B1

    Left-hand side

    Parameter B2

    Right-hand side

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.Or<B.True, B.False> // True
    type test1 = B.Or<B.True, B.True> // True
    type test2 = B.Or<B.Boolean, B.False> // Boolean

type Xor

type Xor<B1 extends Boolean, B2 extends Boolean> = {
0: {
0: 0;
1: 1;
};
1: {
0: 1;
1: 0;
};
}[B1][B2];
  • Logical ^ operator (behaves like the JS one)

    Parameter B1

    Left-hand side

    Parameter B2

    Right-hand side

    Returns

    [[Boolean]]

    Example 1

    import {B} from 'ts-toolbelt'
    type test0 = B.Xor<B.True, B.True> // False
    type test1 = B.Xor<B.False, B.True> // True
    type test2 = B.Xor<B.Boolean, B.True> // Boolean

namespace C

module 'out/Class/_api.d.ts' {}

type Class

type Class<P extends List = any[], R extends object = object> = {
new (...args: P): R;
};
  • Alias to create/describe a class

    Parameter P

    its constructor parameters

    Parameter R

    the object it constructs

    Returns

    class

    Example 1

    import {C} from 'ts-toolbelt'
    type test0 = C.Class<[string, number], {a: string, b: number}>
    declare const SomeClass: test0
    const obj = new SomeClass('foo', 42) // {a: string, b: number}

type Instance

type Instance<C extends Class> = C extends Class<any[], infer R> ? R : any;
  • Get the instance type of a class from a class object

    Parameter C

    * *typeof** class

    Returns

    [[Object]]

    Example 1

    import {C} from 'ts-toolbelt'
    /// `create` takes an instance constructor and creates an instance of it
    declare function create<C extends (new (...args: any[]) => any)>(c: C): C.InstanceOf<C>
    class A {}
    class B {}
    let a = create(A) // A
    let b = create(B) // B

type Parameters

type Parameters<C extends Class> = C extends Class<infer P, any> ? P : never;
  • Get the parameters of a class constructor

    Parameter C

    **typeof** class

    Returns

    [[List]]

    Example 1

    import {C} from 'ts-toolbelt'
    type User = C.Class<[string, string], {firstname: string, lastname: string}>
    type test0 = C.Parameters<User> // [string, string]

namespace Class

module 'out/Class/_api.d.ts' {}

type Class

type Class<P extends List = any[], R extends object = object> = {
new (...args: P): R;
};
  • Alias to create/describe a class

    Parameter P

    its constructor parameters

    Parameter R

    the object it constructs

    Returns

    class

    Example 1

    import {C} from 'ts-toolbelt'
    type test0 = C.Class<[string, number], {a: string, b: number}>
    declare const SomeClass: test0
    const obj = new SomeClass('foo', 42) // {a: string, b: number}

type Instance

type Instance<C extends Class> = C extends Class<any[], infer R> ? R : any;
  • Get the instance type of a class from a class object

    Parameter C

    * *typeof** class

    Returns

    [[Object]]

    Example 1

    import {C} from 'ts-toolbelt'
    /// `create` takes an instance constructor and creates an instance of it
    declare function create<C extends (new (...args: any[]) => any)>(c: C): C.InstanceOf<C>
    class A {}
    class B {}
    let a = create(A) // A
    let b = create(B) // B

type Parameters

type Parameters<C extends Class> = C extends Class<infer P, any> ? P : never;
  • Get the parameters of a class constructor

    Parameter C

    **typeof** class

    Returns

    [[List]]

    Example 1

    import {C} from 'ts-toolbelt'
    type User = C.Class<[string, string], {firstname: string, lastname: string}>
    type test0 = C.Parameters<User> // [string, string]

namespace Community

module 'out/Community/_api.d.ts' {}

type IncludesDeep

type IncludesDeep<
O extends object,
M extends any,
match extends Match = 'default',
limit extends number = 10
> = _IncludesDeep<O, M, match, limit> extends infer X ? Cast<X, Boolean> : never;
  • Check whether O, or its sub-objects have fields that match M where the maximum allowed depth is set with limit.

    Parameter O

    to be inspected

    Parameter M

    to check field type

    Parameter match

    (?='default') to change precision

    Parameter limit

    (?='10') to change the check depth

    Returns

    [[Boolean]]

    Example 1

    ```ts ``` millsp, ctrlplusb

type IsLiteral

type IsLiteral<A extends any, kind extends Kind = Kind> = And<
Or<IsStringLiteral<A>, IsNumberLiteral<A>>,
Extends<A, kind>
>;
  • Determine whether A is literal or not

    Parameter A

    to be checked

    Parameter kind

    (?='string' | 'number') to restrict

    Example 1

    import {A} from 'ts-toolbelt'
    type test0 = A.IsLiteral<1 | 2> // 1
    type test1 = A.IsLiteral<1 | 2, string> // 0
    type test2 = A.IsLiteral<1 | '2', string> // 0 | 1
    type test3 = A.IsLiteral<number> // 0

namespace F

module 'out/Function/_api.d.ts' {}

type AutoPath

type AutoPath<O extends any, P extends string, D extends string = '.'> = _AutoPath<
O,
P,
D
>;
  • Auto-complete, validate, and query the string path of an object O

    Parameter O

    to work on

    Parameter P

    path of O

    Parameter D

    (?='.') delimiter for path

    declare function get<O extends object, P extends string>(
    object: O, path: AutoPath<O, P>
    ): Path<O, Split<P, '.'>>
    declare const user: User
    type User = {
    name: string
    friends: User[]
    }
    // works
    const friendName = get(user, 'friends.40.name')
    const friendFriendName = get(user, 'friends.40.friends.12.name')
    // errors
    const friendNames = get(user, 'friends.40.names')
    const friendFriendNames = get(user, 'friends.40.friends.12.names')

type Compose

type Compose<
mode extends Mode = 'sync',
input extends Input = 'multi'
> = IntersectOf<
{
sync: {
multi: ComposeMultiSync;
list: ComposeListSync;
};
async: {
multi: ComposeMultiAsync;
list: ComposeListAsync;
};
}[mode][input]
>;
  • Compose [[Function]]s together

    Parameter mode

    (?='sync') sync/async (this depends on your implementation)

    Parameter input

    (?='multi') whether you want it to take a list or parameters

    Example 1

    ```ts import {F} from 'ts-toolbelt'

    /// If you are looking for creating types for compose /// Composer will check for input & Compose the output declare const compose: F.Compose

    const a = (a1: number) => ${a1} const c = (c1: string[]) => [c1] const b = (b1: string) => [b1]

    compose(c, b, a)(42)

    /// And if you are looking for an async compose type declare const compose: F.Compose<'async'>

    const a = async (a1: number) => ${a1} const b = async (b1: string) => [b1] const c = async (c1: string[]) => [c1]

    await compose(c, b, a)(42)

type Curry

type Curry<F extends Function> = <
P extends Gaps<Parameters<F>>,
G extends List = GapsOf<P, Parameters<F>>,
R extends any = Return<F>
>(
...p: Gaps<Parameters<F>> | P
) => RequiredKeys<G> extends never ? R : Curry<(...p: G) => R>;
  • Curry a [[Function]]

    Parameter F

    to curry

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    /// If you are looking for creating types for `curry`
    /// It handles placeholders and variable arguments
    declare function curry<Fn extends F.Function>(fn: Fn): F.Curry<Fn>

type Exact

type Exact<A, W> = W extends unknown
? A extends W
? A extends Narrowable
? A
: {
[K in keyof A]: K extends keyof W ? Exact<A[K], W[K]> : never;
}
: W
: never;
  • Force A to comply with W. A must be a shape of W. In other words, A must extend W and have the same properties - no more, no less.

    Parameter A

    Parameter W

type Function

type Function<P extends List = any, R extends any = any> = (...args: P) => R;
  • Alias to create a [[Function]]

    Parameter P

    parameters

    Parameter R

    return type

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    type test0 = F.Function<[string, number], boolean>
    /// (args_0: string, args_1: number) => boolean

type Length

type Length<Fn extends Function> = LLength<Parameters<Fn>>;
  • Extract arguments' length from a [[Function]]

    Parameter F

    to extract from

    Returns

    [[String]] or number

    Example 1

    import {F} from 'ts-toolbelt'
    const fn = (a1: any, a2: any) => {}
    type test0 = F.LengthOf<typeof fn> // 2
    type test1 = F.LengthOf<(a1?: any) => any> // 0 | 1
    type test2 = F.LengthOf<(...a: any[]) => any> // number

type Narrow

type Narrow<A extends any> = Try<A, [], NarrowRaw<A>>;
  • Prevent type widening on generic function parameters

    Parameter A

    to narrow

    Returns

    A

    Example 1

    import {F} from 'ts-toolbelt'
    declare function foo<A extends any[]>(x: F.Narrow<A>): A;
    declare function bar<A extends object>(x: F.Narrow<A>): A;
    const test0 = foo(['e', 2, true, {f: ['g', ['h']]}])
    // `A` inferred : ['e', 2, true, {f: ['g']}]
    const test1 = bar({a: 1, b: 'c', d: ['e', 2, true, {f: ['g']}]})
    // `A` inferred : {a: 1, b: 'c', d: ['e', 2, true, {f: ['g']}]}

type NoInfer

type NoInfer<A extends any> = [A][A extends any ? 0 : never];
  • Explain to TS which function parameter has priority for generic inference

    Parameter A

    to de-prioritize

    Returns

    A

    Example 1

    import {F} from 'ts-toolbelt'
    const fn0 = <A extends any>(a0: A, a1: F.NoInfer<A>): A => {
    return {} as unknown as A // just for the example
    }
    const fn1 = <A extends any>(a0: F.NoInfer<A>, a1: A): A => {
    return {} as unknown as A // just for the example
    }
    const fn2 = <A extends any>(a0: F.NoInfer<A>, a1: F.NoInfer<A>): A => {
    return {} as unknown as A // just for the example
    }
    const test0 = fn0('b', 'a') // error: infer priority is `a0`
    const test1 = fn1('b', 'a') // error: infer priority is `a1`
    const test2 = fn2('b', 'a') // works: infer priority is `a0` | `a1`

    See Also

    • https://stackoverflow.com/questions/56687668

type Parameters

type Parameters<F extends Function> = F extends (...args: infer L) => any
? L
: never;
  • Extract parameters from a [[Function]]

    Parameter F

    to extract from

    Returns

    [[List]]

    Example 1

    import {F} from 'ts-toolbelt'
    const fn = (name: string, age: number) => {}
    type test0 = F.ParamsOf<typeof fn> // [string, number]
    type test1 = F.ParamsOf<(name: string, age: number) => {}> // [string, number]

type Pipe

type Pipe<mode extends Mode = 'sync', input extends Input = 'multi'> = IntersectOf<
{
sync: {
multi: PipeMultiSync;
list: PipeListSync;
};
async: {
multi: PipeMultiAsync;
list: PipeListAsync;
};
}[mode][input]
>;
  • Pipe [[Function]]s together

    Parameter mode

    (?='sync') sync/async (this depends on your implementation)

    Parameter input

    (?='multi') whether you want to take a list or multiple parameters

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    /// If you are looking for creating types for `pipe`:
    declare const pipe: F.Pipe
    const a = (a1: number) => `${a1}`
    const b = (b1: string) => [b1]
    const c = (c1: string[]) => [c1]
    pipe(a, b, c)(42)
    /// And if you are looking for an async `pipe` type:
    declare const pipe: F.Pipe<'async'>
    const a = async (a1: number) => `${a1}`
    const b = async (b1: string) => [b1]
    const c = async (c1: string[]) => [c1]
    await pipe(a, b, c)(42)

type Promisify

type Promisify<F extends Function> = (...args: Parameters<F>) => Promise<Return<F>>;
  • Creates a promisified version of a Function F

    Parameter F

    to promisify

    Returns

    async F

    Example 1

    import {F} from 'ts-toolbelt'
    type test0 = F.Promisify<(a: number) => number> // (a: number) => Promise<number>

type Return

type Return<F extends Function> = F extends (...args: List) => infer R ? R : never;
  • Extract the return type of a [[Function]]

    Parameter F

    to extract from

    Returns

    [[Any]]

    Example 1

    import {F} from 'ts-toolbelt'
    const fn = () => true
    type test0 = F.ReturnOf<typeof fn> // boolean
    type test1 = F.ReturnOf<() => true> // true

type UnCurry

type UnCurry<F extends Curry<any>> = F extends Curry<infer UF> ? UF : never;
  • Undoes the work that was done by [[Curry]]

    Parameter F

    to uncurry

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    type test0 = F.Curry<(a: string, b: number) => boolean>
    declare const foo: test0
    const res0 = foo('a') // F.Curry<(b: number) => boolean> & ((b: number) => boolean)
    type test1 = F.UnCurry<test0> // (a: string, b: number) => boolean
    declare const bar: test1
    const res1 = bar('a') // TS2554: Expected 2 arguments, but got 1.

type ValidPath

type ValidPath<O extends object, Path extends List<AKey>> = O extends unknown
? Path extends unknown
? _ValidPath<O, Path>
: never
: never;
  • Replaces invalid parts of a path with never

    Parameter O

    to be inspected

    Parameter Path

    to be validated

    Returns

    [[Index]][]

    Example 1

    import {A, L, O} from 'ts-toolbelt'
    // Get a property in an object `o` at any depth with `path`
    // `A.Cast<P, O.ValidPath<O, P>>` makes sure `path` is valid
    const getAt = <
    O extends object,
    P extends L.List<A.Index>
    >(o: O, path: A.Cast<P, O.ValidPath<O, P>>): O.Path<O, P> => {
    let valueAt = o
    for (const p of path)
    valueAt = valueAt[p]
    return valueAt as any
    }
    const test0 = getAt({a: {b: {c: 1}}}, ['a', 'b'] as const) // {c: number}
    const test1 = getAt({a: {b: {c: 1}}} as const, ['a', 'b'] as const) // {c: 1}
    const test2 = getAt({a: {b: {c: 1}}}, ['x'] as const) // error

namespace Function

module 'out/Function/_api.d.ts' {}

type AutoPath

type AutoPath<O extends any, P extends string, D extends string = '.'> = _AutoPath<
O,
P,
D
>;
  • Auto-complete, validate, and query the string path of an object O

    Parameter O

    to work on

    Parameter P

    path of O

    Parameter D

    (?='.') delimiter for path

    declare function get<O extends object, P extends string>(
    object: O, path: AutoPath<O, P>
    ): Path<O, Split<P, '.'>>
    declare const user: User
    type User = {
    name: string
    friends: User[]
    }
    // works
    const friendName = get(user, 'friends.40.name')
    const friendFriendName = get(user, 'friends.40.friends.12.name')
    // errors
    const friendNames = get(user, 'friends.40.names')
    const friendFriendNames = get(user, 'friends.40.friends.12.names')

type Compose

type Compose<
mode extends Mode = 'sync',
input extends Input = 'multi'
> = IntersectOf<
{
sync: {
multi: ComposeMultiSync;
list: ComposeListSync;
};
async: {
multi: ComposeMultiAsync;
list: ComposeListAsync;
};
}[mode][input]
>;
  • Compose [[Function]]s together

    Parameter mode

    (?='sync') sync/async (this depends on your implementation)

    Parameter input

    (?='multi') whether you want it to take a list or parameters

    Example 1

    ```ts import {F} from 'ts-toolbelt'

    /// If you are looking for creating types for compose /// Composer will check for input & Compose the output declare const compose: F.Compose

    const a = (a1: number) => ${a1} const c = (c1: string[]) => [c1] const b = (b1: string) => [b1]

    compose(c, b, a)(42)

    /// And if you are looking for an async compose type declare const compose: F.Compose<'async'>

    const a = async (a1: number) => ${a1} const b = async (b1: string) => [b1] const c = async (c1: string[]) => [c1]

    await compose(c, b, a)(42)

type Curry

type Curry<F extends Function> = <
P extends Gaps<Parameters<F>>,
G extends List = GapsOf<P, Parameters<F>>,
R extends any = Return<F>
>(
...p: Gaps<Parameters<F>> | P
) => RequiredKeys<G> extends never ? R : Curry<(...p: G) => R>;
  • Curry a [[Function]]

    Parameter F

    to curry

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    /// If you are looking for creating types for `curry`
    /// It handles placeholders and variable arguments
    declare function curry<Fn extends F.Function>(fn: Fn): F.Curry<Fn>

type Exact

type Exact<A, W> = W extends unknown
? A extends W
? A extends Narrowable
? A
: {
[K in keyof A]: K extends keyof W ? Exact<A[K], W[K]> : never;
}
: W
: never;
  • Force A to comply with W. A must be a shape of W. In other words, A must extend W and have the same properties - no more, no less.

    Parameter A

    Parameter W

type Function

type Function<P extends List = any, R extends any = any> = (...args: P) => R;
  • Alias to create a [[Function]]

    Parameter P

    parameters

    Parameter R

    return type

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    type test0 = F.Function<[string, number], boolean>
    /// (args_0: string, args_1: number) => boolean

type Length

type Length<Fn extends Function> = LLength<Parameters<Fn>>;
  • Extract arguments' length from a [[Function]]

    Parameter F

    to extract from

    Returns

    [[String]] or number

    Example 1

    import {F} from 'ts-toolbelt'
    const fn = (a1: any, a2: any) => {}
    type test0 = F.LengthOf<typeof fn> // 2
    type test1 = F.LengthOf<(a1?: any) => any> // 0 | 1
    type test2 = F.LengthOf<(...a: any[]) => any> // number

type Narrow

type Narrow<A extends any> = Try<A, [], NarrowRaw<A>>;
  • Prevent type widening on generic function parameters

    Parameter A

    to narrow

    Returns

    A

    Example 1

    import {F} from 'ts-toolbelt'
    declare function foo<A extends any[]>(x: F.Narrow<A>): A;
    declare function bar<A extends object>(x: F.Narrow<A>): A;
    const test0 = foo(['e', 2, true, {f: ['g', ['h']]}])
    // `A` inferred : ['e', 2, true, {f: ['g']}]
    const test1 = bar({a: 1, b: 'c', d: ['e', 2, true, {f: ['g']}]})
    // `A` inferred : {a: 1, b: 'c', d: ['e', 2, true, {f: ['g']}]}

type NoInfer

type NoInfer<A extends any> = [A][A extends any ? 0 : never];
  • Explain to TS which function parameter has priority for generic inference

    Parameter A

    to de-prioritize

    Returns

    A

    Example 1

    import {F} from 'ts-toolbelt'
    const fn0 = <A extends any>(a0: A, a1: F.NoInfer<A>): A => {
    return {} as unknown as A // just for the example
    }
    const fn1 = <A extends any>(a0: F.NoInfer<A>, a1: A): A => {
    return {} as unknown as A // just for the example
    }
    const fn2 = <A extends any>(a0: F.NoInfer<A>, a1: F.NoInfer<A>): A => {
    return {} as unknown as A // just for the example
    }
    const test0 = fn0('b', 'a') // error: infer priority is `a0`
    const test1 = fn1('b', 'a') // error: infer priority is `a1`
    const test2 = fn2('b', 'a') // works: infer priority is `a0` | `a1`

    See Also

    • https://stackoverflow.com/questions/56687668

type Parameters

type Parameters<F extends Function> = F extends (...args: infer L) => any
? L
: never;
  • Extract parameters from a [[Function]]

    Parameter F

    to extract from

    Returns

    [[List]]

    Example 1

    import {F} from 'ts-toolbelt'
    const fn = (name: string, age: number) => {}
    type test0 = F.ParamsOf<typeof fn> // [string, number]
    type test1 = F.ParamsOf<(name: string, age: number) => {}> // [string, number]

type Pipe

type Pipe<mode extends Mode = 'sync', input extends Input = 'multi'> = IntersectOf<
{
sync: {
multi: PipeMultiSync;
list: PipeListSync;
};
async: {
multi: PipeMultiAsync;
list: PipeListAsync;
};
}[mode][input]
>;
  • Pipe [[Function]]s together

    Parameter mode

    (?='sync') sync/async (this depends on your implementation)

    Parameter input

    (?='multi') whether you want to take a list or multiple parameters

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    /// If you are looking for creating types for `pipe`:
    declare const pipe: F.Pipe
    const a = (a1: number) => `${a1}`
    const b = (b1: string) => [b1]
    const c = (c1: string[]) => [c1]
    pipe(a, b, c)(42)
    /// And if you are looking for an async `pipe` type:
    declare const pipe: F.Pipe<'async'>
    const a = async (a1: number) => `${a1}`
    const b = async (b1: string) => [b1]
    const c = async (c1: string[]) => [c1]
    await pipe(a, b, c)(42)

type Promisify

type Promisify<F extends Function> = (...args: Parameters<F>) => Promise<Return<F>>;
  • Creates a promisified version of a Function F

    Parameter F

    to promisify

    Returns

    async F

    Example 1

    import {F} from 'ts-toolbelt'
    type test0 = F.Promisify<(a: number) => number> // (a: number) => Promise<number>

type Return

type Return<F extends Function> = F extends (...args: List) => infer R ? R : never;
  • Extract the return type of a [[Function]]

    Parameter F

    to extract from

    Returns

    [[Any]]

    Example 1

    import {F} from 'ts-toolbelt'
    const fn = () => true
    type test0 = F.ReturnOf<typeof fn> // boolean
    type test1 = F.ReturnOf<() => true> // true

type UnCurry

type UnCurry<F extends Curry<any>> = F extends Curry<infer UF> ? UF : never;
  • Undoes the work that was done by [[Curry]]

    Parameter F

    to uncurry

    Returns

    [[Function]]

    Example 1

    import {F} from 'ts-toolbelt'
    type test0 = F.Curry<(a: string, b: number) => boolean>
    declare const foo: test0
    const res0 = foo('a') // F.Curry<(b: number) => boolean> & ((b: number) => boolean)
    type test1 = F.UnCurry<test0> // (a: string, b: number) => boolean
    declare const bar: test1
    const res1 = bar('a') // TS2554: Expected 2 arguments, but got 1.

type ValidPath

type ValidPath<O extends object, Path extends List<AKey>> = O extends unknown
? Path extends unknown
? _ValidPath<O, Path>
: never
: never;
  • Replaces invalid parts of a path with never

    Parameter O

    to be inspected

    Parameter Path

    to be validated

    Returns

    [[Index]][]

    Example 1

    import {A, L, O} from 'ts-toolbelt'
    // Get a property in an object `o` at any depth with `path`
    // `A.Cast<P, O.ValidPath<O, P>>` makes sure `path` is valid
    const getAt = <
    O extends object,
    P extends L.List<A.Index>
    >(o: O, path: A.Cast<P, O.ValidPath<O, P>>): O.Path<O, P> => {
    let valueAt = o
    for (const p of path)
    valueAt = valueAt[p]
    return valueAt as any
    }
    const test0 = getAt({a: {b: {c: 1}}}, ['a', 'b'] as const) // {c: number}
    const test1 = getAt({a: {b: {c: 1}}} as const, ['a', 'b'] as const) // {c: 1}
    const test2 = getAt({a: {b: {c: 1}}}, ['x'] as const) // error

namespace I

module 'out/Iteration/_api.d.ts' {}

type Iteration

type Iteration = [
value: number,
sign: '-' | '0' | '+',
prev: keyof IterationMap,
next: keyof IterationMap,
oppo: keyof IterationMap
];
  • An entry of IterationMap

type IterationOf

type IterationOf<N extends number> = `${N}` extends keyof IterationMap
? IterationMap[`${N}`]
: IterationMap['__'];
  • Transform a number into an [[Iteration]] (to use [[Prev]], [[Next]], & [[Pos]])

    Parameter N

    to transform

    Returns

    [[Iteration]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
    type next = I.Next<i> // ["0", "2", "1", 1, "+"]
    type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
    type nnext = I.Pos<next> // +1
    type nprev = I.Pos<prev> // -1

type Key

type Key<I extends Iteration> = `${I[0]}`;
  • Get the position of I (**string**)

    Parameter I

    to query

    Returns

    [[String]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Key<i> // '20'
    type test1 = I.Key<I.Next<i>> // '21'

type Next

type Next<I extends Iteration> = IterationMap[I[3]];
  • Move I's position forward

    Parameter I

    to move

    Returns

    [[Iteration]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Pos<i> // 20
    type test1 = I.Pos<I.Next<i>> // 21

type Pos

type Pos<I extends Iteration> = I[0];
  • Get the position of I (**number**)

    Parameter I

    to query

    Returns

    number

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Pos<i> // 20
    type test1 = I.Pos<I.Next<i>> // 21

type Prev

type Prev<I extends Iteration> = IterationMap[I[2]];
  • Move I's position backwards

    Parameter I

    to move

    Returns

    [[Iteration]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Pos<i> // 20
    type test1 = I.Pos<I.Prev<i>> // 19

namespace Iteration

module 'out/Iteration/_api.d.ts' {}

type Iteration

type Iteration = [
value: number,
sign: '-' | '0' | '+',
prev: keyof IterationMap,
next: keyof IterationMap,
oppo: keyof IterationMap
];
  • An entry of IterationMap

type IterationOf

type IterationOf<N extends number> = `${N}` extends keyof IterationMap
? IterationMap[`${N}`]
: IterationMap['__'];
  • Transform a number into an [[Iteration]] (to use [[Prev]], [[Next]], & [[Pos]])

    Parameter N

    to transform

    Returns

    [[Iteration]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
    type next = I.Next<i> // ["0", "2", "1", 1, "+"]
    type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
    type nnext = I.Pos<next> // +1
    type nprev = I.Pos<prev> // -1

type Key

type Key<I extends Iteration> = `${I[0]}`;
  • Get the position of I (**string**)

    Parameter I

    to query

    Returns

    [[String]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Key<i> // '20'
    type test1 = I.Key<I.Next<i>> // '21'

type Next

type Next<I extends Iteration> = IterationMap[I[3]];
  • Move I's position forward

    Parameter I

    to move

    Returns

    [[Iteration]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Pos<i> // 20
    type test1 = I.Pos<I.Next<i>> // 21

type Pos

type Pos<I extends Iteration> = I[0];
  • Get the position of I (**number**)

    Parameter I

    to query

    Returns

    number

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Pos<i> // 20
    type test1 = I.Pos<I.Next<i>> // 21

type Prev

type Prev<I extends Iteration> = IterationMap[I[2]];
  • Move I's position backwards

    Parameter I

    to move

    Returns

    [[Iteration]]

    Example 1

    import {I} from 'ts-toolbelt'
    type i = I.IterationOf<'20'>
    type test0 = I.Pos<i> // 20
    type test1 = I.Pos<I.Prev<i>> // 19

namespace L

module 'out/List/_api.d.ts' {}

type Append

type Append<L extends List, A extends any> = [...L, A];
  • Add an element A at the end of L.

    Parameter L

    to append to

    Parameter A

    to be added to

    Returns

    [[List]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
    type test1 = L.Append<[], 'a'> // ['a']
    type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
    type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]

type Assign

type Assign<
L extends List,
Ls extends List<List>,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = never
> = Cast<OAssign<L, Ls, depth, ignore, fill>, List>;
  • Assign a list of [[List]] into L with [[Merge]]. Merges from left to right, first items get overridden by the next ones (last-in overrides).

    Parameter L

    to assign to

    Parameter Ls

    to assign

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=undefined) types of O to be replaced with ones of O1

    Returns

    [[Object]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = Assign<[1, 2, 3], [[2, 1]]> // [2, 1, 3]
    type test1 = Assign<[], [[1, 2, 3, 4], [2, 4, 6]]> // [2, 4, 6, 4]
    type test2 = Assign<[0, 0, 0, 0, 0], [[0, 1], [0, 2, 0, 4?]]> // [0, 2, 0, 0 | 4, 0]

type AtLeast

type AtLeast<L extends List, K extends Key = Keys<L>> = OAtLeast<
ObjectOf<L>,
`${K & number}` | K
> extends infer U
? U extends unknown
? _ListOf<U & {}>
: never
: never;
  • Make that at least one of the keys K are required in L at a time.

    Parameter L

    to make required

    Parameter K

    (?=keyof L) to choose fields

    Returns

    [[List]] [[Union]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.AtLeast<[1, 2, 3], 0> // [1, 2 | undefined, 3 | undefined]
    type test1 = L.AtLeast<[1, 2, 3], 0 | 1> // [1, 2 | undefined, 3 | undefined] | [1 | undefined, 2, 3 | undefined]
    type test2 = L.AtLeast<[1, 2, 3]>
    // | [1, 2, 3]
    // | [1, 2 | undefined, 3 | undefined]
    // | [1 | undefined, 2, 3 | undefined]
    // | [1 | undefined, 2 | undefined, 3]

type Compulsory

type Compulsory<L extends List, depth extends Depth = 'flat'> = Cast<
CompulsoryPart<L, depth>,
List
>;
  • Make that L's fields cannot be [[Nullable]] or [[Optional]] (it's like [[Required]] & [[NonNullable]] at once).

    Parameter L

    to make compulsory

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    * import {L} from 'ts-toolbelt'
    type test0 = L.Compulsory<[1, 2, 3?, 4?]> // [1, 2, 3, 4]
    type test1 = L.Compulsory<['a', 'b' | undefined, 'c', 'd', 'e' | null]> // ['a', 'b', 'c', 'd', 'e']

type CompulsoryKeys

type CompulsoryKeys<L extends List> = OCompulsoryKeys<ObjectOf<L>>;
  • Get the keys of L that are [[Compulsory]]

    (⚠️ needs --strictNullChecks enabled)

    Parameter L

    Returns

    [[Key]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.CompulsoryKeys<[1, 2, 3]> // {0: 1, 1: 2, 2: 3}

type Concat

type Concat<L extends List, L1 extends List> = [...L, ...L1];
  • Attach L1 at the end of L

    Parameter L

    to concat with

    Parameter L1

    to be attached

    Returns

    [[List]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.Concat<[1, 2], [3, 4]> // [1, 2, 3, 4]
    type test1 = L.Concat<[1, 2], [[3], 4]> // [1, 2, [3], 4]
    type test2 = L.Concat<[1, 2], number[]> // [1, 2, ...number[]]
    type test3 = L.Concat<readonly [1, 2], readonly [3]> // [1, 2, 3]

type Diff

type Diff<L extends List, L1 extends List, match extends Match = 'default'> = ListOf<
ODiff<ObjectOf<L>, ObjectOf<L1>, match>
>;
  • Get a [[List]] that is the difference between L & L1 (L's differences have priority over L1's if entries overlap) (If match = 'default', no type checks are done)

    Parameter L

    to check differences with

    Parameter L1

    to check differences against

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type Drop

type Drop<
L extends List,
N extends number,
way extends Way = '->'
> = L extends unknown ? (N extends unknown ? _Drop<L, N, way> : never) : never;
  • Remove N entries out of L

    Parameter L

    to remove from

    Parameter N

    to remove out

    Parameter way

    (?='->') from front: '->', from end: '<-'

    Returns

    [[List]]

    Example 1

    ```ts ```

type Either

type Either<L extends List, K extends Key, strict extends Boolean = 1> = OEither<
ObjectOf<L>,
`${K & number}` | K,
strict
> extends infer OE
? OE extends unknown
? _ListOf<OE & {}>
: never
: never;
  • Split L into a [[Union]] with K keys in such a way that none of the keys are ever present with one another within the different unions.

    Parameter L

    to split

    Parameter K

    to split with

    Parameter strict

    (?=1) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863

    Returns

    [[List]] [[Union]]

    Example 1

    ```ts ```

type Exclude

type Exclude<
L extends List,
L1 extends List,
match extends Match = 'default'
> = ListOf<OExclude<ObjectOf<L>, ObjectOf<L1>, match>>;
  • Exclude the entries of L1 out of L (If match = 'default', no type checks are done)

    Parameter L

    to remove from

    Parameter L1

    to remove out

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type ExcludeKeys

type ExcludeKeys<
L extends List,
L1 extends List,
match extends Match = 'default'
> = OExcludeKeys<ObjectOf<L>, ObjectOf<L1>, match>;
  • Exclude the keys of L1 out of the keys of L (If match = 'default', no type checks are done)

    Parameter L

    to remove the keys from

    Parameter L1

    to remove the keys out

    Parameter match

    (?='default') to change precision

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Extract

type Extract<L extends List, From extends number, To extends number> = Pick<
L,
KeySet<From, To>
>;
  • Pick a range of entries (portion) from L

    Parameter L

    to pick from

    Parameter From

    to start with

    Parameter To

    to end with

    Returns

    [[List]]

    Example 1

    ```ts ```

type Filter

type Filter<L extends List, M extends any, match extends Match = 'default'> = ListOf<
OFilter<ObjectOf<L>, M, match>
>;
  • Filter out of L the entries that match M

    Parameter L

    to remove from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type FilterKeys

type FilterKeys<
L extends List,
M extends any,
match extends Match = 'default'
> = OFilterKeys<ObjectOf<L>, M, match>;
  • Filter out the keys of L which entries match M

    Parameter L

    to remove from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Flatten

type Flatten<
L extends List,
strict extends Boolean = 1,
limit extends number = number
> = L extends unknown ? _Flatten<L, strict, limit> : never;
  • Remove all dimensions of L (10 max)

    Parameter L

    to un-nest

    Parameter strict

    (?=1) 0 to not preserve tuples

    Parameter limit

    (?=string) to stop un-nesting at

    Returns

    [[List]]

    Example 1

    ```ts ```

type Group

type Group<L extends List, N extends number> = L extends unknown
? N extends unknown
? _Group<L, N>
: never
: never;
  • Split L into sub-[[List]]s every N

    Parameter L

    to group

    Parameter N

    to split at

    Returns

    [[List]]

    Example 1

    ```ts ```

type Has

type Has<
L extends List,
K extends Key,
M extends any = any,
match extends Match = 'default'
> = OHas<ObjectOf<L>, `${K & number}` | K, M, match>;
  • Check whether L has a entry of key K that matches M

    Parameter L

    to be inspected

    Parameter K

    to choose entry

    Parameter M

    (?=any) to check entry type

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    ```ts ```

type HasPath

type HasPath<
L extends List,
Path extends List<Key>,
M extends any = any,
match extends Match = 'default'
> = OHasPath<ObjectOf<L>, Path, M, match>;
  • Check whether L has nested entries that match M

    Parameter L

    to be inspected

    Parameter Path

    to be followed

    Parameter M

    (?=any) to check entry type

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    ```ts ```

type Head

type Head<L extends List> = Length<L> extends 0 ? never : L[0];
  • Get the first entry of L

    Parameter L

    to extract from

    Returns

    [[Any]]

    Example 1

    ```ts ```

type Includes

type Includes<
L extends List,
M extends any,
match extends Match = 'default'
> = OIncludes<ObjectOf<L>, M, match>;
  • Check whether L has entries that match M

    Parameter L

    to be inspected

    Parameter M

    to check entry type

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    ```ts ```

type Intersect

type Intersect<
L extends List,
L1 extends List,
match extends Match = 'default'
> = ListOf<OIntersect<ObjectOf<L>, ObjectOf<L1>, match>>;
  • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

    Parameter L

    to check similarities with

    Parameter L1

    to check similarities against

    Returns

    [[List]]

    Example 1

    ```ts ```

type IntersectKeys

type IntersectKeys<
L extends List,
L1 extends List,
match extends Match = 'default'
> = OIntersectKeys<ObjectOf<L>, L1, match>;
  • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

    Parameter L

    to check similarities with

    Parameter L1

    to check similarities against

    Returns

    [[Key]]

    Example 1

    ```ts ```

type KeySet

type KeySet<From extends number, To extends number> = UnionOf<Range<From, To, '->'>>;
  • Create a set of keys

    Parameter From

    to start with

    Parameter To

    to end with

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Last

type Last<L extends List> = L[Length<Tail<L>>];
  • Get the last entry of L

    Parameter L

    to extract from

    Returns

    [[Any]]

    Example 1

    ```ts ```

type LastKey

type LastKey<L extends List> = Length<Tail<L>>;
  • Get the last index of L

    Parameter L

    to get from

    Returns

    number

    Example 1

    ```ts ```

type Length

type Length<L extends List> = L['length'];
  • Get the length of L

    Parameter L

    to get length

    Returns

    [[String]] or number

    Example 1

    ```ts ```

type List

type List<A = any> = ReadonlyArray<A>;
  • A [[List]]

    Parameter A

    its type

    Returns

    [[List]]

    Example 1

    type list0 = [1, 2, 3]
    type list1 = number[]

type Longest

type Longest<L extends List, L1 extends List> = L extends unknown
? L1 extends unknown
? {
0: L1;
1: L;
}[Has<keyof L, keyof L1>]
: never
: never;
  • Get the longest [[List]] of L & L1 (L has priority if both lengths are equal)

    Parameter L

    to compare length

    Parameter L1

    to compare length

    Returns

    L | L1

    Example 1

    ```ts ```

type Merge

type Merge<
L extends List,
L1 extends List,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = undefined
> = Cast<OMerge<L, L1, depth, ignore, fill>, List>;
  • Accurately merge the fields of L with the ones of L1. It is equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] fields will be handled gracefully.

    (⚠️ needs --strictNullChecks enabled)

    Parameter L

    to complete

    Parameter L1

    to copy from

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=undefined) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type MergeAll

type MergeAll<
L extends List,
Ls extends List<List>,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = undefined
> = Cast<OMergeAll<L, Ls, depth, ignore, fill>, List>;
  • [[Merge]] a list of [[List]]s into L. Merges from left to right, first items get completed by the next ones (last-in completes).

    Parameter L

    to start with

    Parameter Ls

    to merge

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=undefined) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type Modify

type Modify<L extends List, LMod extends List> = Cast<
{
[K in keyof LMod]: Replace<LMod[K], x, Exclude<At<L, K>, undefined>>;
},
List
>;
  • Modify L with LMod & the [[x]] placeholder

    Parameter L

    to copy from

    Parameter LMod

    to copy to

    Returns

    [[List]]

    Example 1

    ```ts ```

type NonNullable

type NonNullable<
L extends List,
K extends Key = Key,
depth extends Depth = 'flat'
> = Cast<NonNullablePart<L, `${K & number}` | K, depth>, List>;
  • Make some entries of L not nullable (deeply or not)

    Parameter L

    to make non nullable

    Parameter K

    (?=Key) to choose fields

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type NonNullableKeys

type NonNullableKeys<L extends List> = ONonNullableKeys<ObjectOf<L>>;
  • Get the keys of L that are non-nullable

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Nullable

type Nullable<L extends List, K extends Key = Key> = Cast<
Update<L, `${K & number}` | K, x | null | undefined>,
List
>;
  • Make some entries of L nullable (deeply or not)

    Parameter L

    to make nullable

    Parameter K

    (?=Key) to choose fields

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type NullableKeys

type NullableKeys<L extends List> = ONullableKeys<ObjectOf<L>>;
  • Get the keys of L that are nullable

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type ObjectOf

type ObjectOf<O extends List> = O extends unknown
? number extends Length<O>
? _Pick<O, number>
: _Omit<O, keyof any[]>
: never;
  • Transform a [[List]] into an [[Object]] equivalent

    Parameter L

    to transform

    Returns

    [[Object]]

    Example 1

    ```ts ```

type Omit

type Omit<L extends List, K extends Key> = L extends unknown ? _Omit<L, K> : never;
  • Remove out of L the entries of key K

    Parameter L

    to remove from

    Parameter K

    to chose entries

    Returns

    [[List]]

    Example 1

    ```ts ```

type Optional

type Optional<L extends List, depth extends Depth = 'flat'> = Cast<
OptionalPart<L, depth>,
List
>;
  • Make L optional (deeply or not)

    Parameter L

    to make optional

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type OptionalKeys

type OptionalKeys<L extends List> = OOptionalKeys<ObjectOf<L>>;
  • Get the keys of L that are optional

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Overwrite

type Overwrite<L extends List, L1 extends object> = Cast<OOverwrite<L, L1>, List>;
  • Update the entries of L with the ones of L1

    Parameter L

    to update

    Parameter L1

    to update with

    Returns

    [[Object]]

    Example 1

    ```ts ```

type Partial

type Partial<L extends List, depth extends Depth = 'flat'> = Cast<
OPartial<L, depth>,
List
>;
  • Make all fields of O optional (deeply or not)

    Parameter L

    to make optional

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    import {O} from 'ts-toolbelt'
    type L = [1, 2, 3, [4, [5]]]
    type test0 = O.Partial<L>
    type test1 = O.Partial<L, 'deep'>

type Patch

type Patch<
L extends List,
L1 extends List,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = never
> = Cast<OPatch<L, L1, depth, ignore, fill>, List>;
  • Complete the fields of L with the ones of L1. This is a version of [[Merge]] that does NOT handle optional fields, it only completes fields of O with the ones of O1 if they don't exist.

    (⚠️ needs --strictNullChecks enabled)

    Parameter L

    to complete

    Parameter L1

    to copy from

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=never) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type PatchAll

type PatchAll<
O extends List,
Ls extends List<List>,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = never
> = Cast<OPatchAll<O, Ls, depth, ignore, fill>, List>;
  • [[Patch]] a list of [[List]]s into L. Patches from left to right, first items get completed by the next ones (last-in completes).

    Parameter O

    to start with

    Parameter Os

    to patch

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=never) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type Path

type Path<L extends List, Path extends List<Key>> = OPath<L, Path>;
  • Get in L the type of nested properties

    Parameter L

    to be inspected

    Parameter Path

    to be followed

    Returns

    [[Any]]

    Example 1

    ```ts ```

type Paths

type Paths<L extends List> = OPaths<ObjectOf<L>>;
  • Get all the possible paths of L (⚠️ this won't work with circular-refs)

    Parameter L

    to be inspected

    Returns

    [[String]][]

    Example 1

    ```ts ```

type Pick

type Pick<L extends List, K extends Key> = L extends unknown ? _Pick<L, K> : never;
  • Extract out of L the entries of key K

    Parameter L

    to extract from

    Parameter K

    to chose entries

    Returns

    [[List]]

    Example 1

    ```ts ```

type Pop

type Pop<L extends List> = L extends
| readonly [...infer LBody, any]
| readonly [...infer LBody, any?]
? LBody
: L;
  • Remove the last element out of L

    Parameter L

    to remove from

    Returns

    [[List]]

    Example 1

    ```ts ```

type Prepend

type Prepend<L extends List, A extends any> = [A, ...L];
  • Add an element A at the beginning of L

    Parameter L

    to append to

    Parameter A

    to be added to

    Returns

    [[List]]

    Example 1

    ```ts ```

type Readonly

type Readonly<L extends List, depth extends Depth = 'flat'> = Cast<
ReadonlyPart<L, depth>,
List
>;
  • Make L readonly (deeply or not)

    Parameter L

    to make readonly

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type ReadonlyKeys

type ReadonlyKeys<L extends List> = OReadonlyKeys<ObjectOf<L>>;
  • Get the keys of L that are readonly

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Remove

type Remove<L extends List, From extends number, To extends number> = Omit<
L,
KeySet<From, To>
>;
  • Remove out of L a range of entries

    Parameter L

    to remove from

    Parameter From

    to start from

    Parameter To

    to end with

    Returns

    [[List]]

    Example 1

    ```ts ```

type Repeat

type Repeat<A extends any, N extends number, L extends List = []> = N extends unknown
? L extends unknown
? _Repeat<A, N, L>
: never
: never;
  • Fill a [[List]] with N times A

    Parameter A

    to fill with

    Parameter N

    to repeat it

    Parameter L

    (?=[]) to be filled

    Returns

    [[List]]

    Example 1

    ```ts ```

type Replace

type Replace<
L extends List,
M extends any,
A extends any,
match extends Match = 'default'
> = Cast<OReplace<L, M, A, match>, List>;
  • Update with A the entries of L that match M

    Parameter O

    to update

    Parameter M

    to select fields

    Parameter A

    to update with

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type Required

type Required<L extends List, depth extends Depth = 'flat'> = Cast<
RequiredPart<L, depth>,
List
>;
  • Make L required (deeply or not)

    Parameter L

    to make required

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type RequiredKeys

type RequiredKeys<L extends List> = ORequiredKeys<ObjectOf<L>>;
  • Get the keys of L that are readonly

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Reverse

type Reverse<L extends List> = L extends unknown ? _Reverse<L> : never;
  • Turn a [[List]] the other way around

    Parameter L

    to reverse

    Parameter LO

    (?=[]) to prepend to

    Returns

    [[List]]

    Example 1

    ```ts ```

type Select

type Select<L extends List, M extends any, match extends Match = 'default'> = ListOf<
OSelect<ObjectOf<L>, M, match>
>;
  • Extract the entries of L that match M

    Parameter L

    to extract from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type SelectKeys

type SelectKeys<
L extends List,
M extends any,
match extends Match = 'default'
> = OSelectKeys<ObjectOf<L>, M, match>;
  • Get the keys of L which entries match M

    Parameter L

    to extract from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Shortest

type Shortest<L extends List, L1 extends List> = L extends unknown
? L1 extends unknown
? {
0: L1;
1: L;
}[Has<keyof L1, keyof L>]
: never
: never;
  • Get the shortest [[List]] of L & L1 (L has priority if both lengths are equal)

    Parameter L

    to compare length

    Parameter L1

    to compare length

    Returns

    L | L1

    Example 1

    ```ts ```

type Tail

type Tail<L extends List> = L extends readonly []
? L
: L extends readonly [any?, ...infer LTail]
? LTail
: L;
  • Remove the first item out of a [[List]]

    Parameter L

    Returns

    [[List]]

    Example 1

    ```ts ```

type Take

type Take<
L extends List,
N extends number,
way extends Way = '->'
> = L extends unknown ? (N extends unknown ? _Take<L, N, way> : never) : never;
  • Extract N entries out of L

    Parameter L

    to extract from

    Parameter N

    to extract out

    Parameter way

    (?='->') to extract from end

    Returns

    [[List]]

    Example 1

    ```ts ```

type Undefinable

type Undefinable<L extends List, K extends Key = Key> = Cast<
Update<L, `${K & number}` | K, x | undefined>,
List
>;
  • Make some entries of L not undefined (deeply or not)

    Parameter L

    to make non nullable

    Parameter K

    (?=Key) to choose fields

    Returns

    [[List]]

    Example 1

    ```ts ```

type UndefinableKeys

type UndefinableKeys<L extends List> = OUndefinableKeys<ObjectOf<L>>;
  • Get the keys of L that are undefined

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Unionize

type Unionize<L extends List, L1 extends List, K extends Key = Key> = {
[P in keyof L]: P extends K ? L[P] | At<L1, P> : L[P];
};
  • Make the fields of L union the ones of L1

    Parameter L

    to union from

    Parameter L1

    to union with

    Parameter K

    (?=Key) to do choose fields

    Returns

    [[List]]

    Example 1

    ```ts ```

type UnionOf

type UnionOf<L extends List> = L[number];
  • Transform a [[List]] into an [[Union]]

    Parameter L

    to transform

    Returns

    [[Any]]

    Example 1

    ```ts ```

type UnNest

type UnNest<L extends List, strict extends Boolean = 1> = L extends unknown
? _UnNest<L, strict>
: never;
  • Remove a dimension of L

    Parameter L

    to un-nest

    Parameter strict

    (?=1) 0 to not preserve tuples

    Returns

    [[List]]

    Example 1

    ```ts ```

type Update

type Update<L extends List, K extends Key, A extends any> = Cast<
OUpdate<L, `${K & number}` | K, A>,
List
>;
  • Update in L the entries of key K with A. Use the [[x]] placeholder to get the current field type.

    Parameter L

    to update

    Parameter K

    to chose fields

    Parameter A

    to update with

    Returns

    [[List]]

    Example 1

    ```ts ```

type Writable

type Writable<L extends List, depth extends Depth = 'flat'> = Cast<
WritablePart<L, depth>,
List
>;
  • Make L writable (deeply or not)

    Parameter L

    to make writable

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type WritableKeys

type WritableKeys<L extends List> = OWritableKeys<ObjectOf<L>>;
  • Get the keys of L that are writable

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Zip

type Zip<L extends List, L1 extends List> = L extends unknown
? L1 extends unknown
? _Zip<L, L1>
: never
: never;
  • Pair up the entries of L with L1

    Parameter L

    to pair up

    Parameter L1

    to pair up with

    Returns

    [[List]]

    Example 1

    ```ts ```

type ZipObj

type ZipObj<LKeys extends List<Key>, LFields extends List> = LKeys extends unknown
? LFields extends unknown
? _ZipObj<LKeys, LFields>
: never
: never;
  • Create an [[Object]] from [[List]]s of keys & fields

    Parameter LKeys

    its keys

    Parameter LFields

    its fields

    Returns

    [[Object]]

    Example 1

    ```ts ```

namespace List

module 'out/List/_api.d.ts' {}

type Append

type Append<L extends List, A extends any> = [...L, A];
  • Add an element A at the end of L.

    Parameter L

    to append to

    Parameter A

    to be added to

    Returns

    [[List]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
    type test1 = L.Append<[], 'a'> // ['a']
    type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
    type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]

type Assign

type Assign<
L extends List,
Ls extends List<List>,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = never
> = Cast<OAssign<L, Ls, depth, ignore, fill>, List>;
  • Assign a list of [[List]] into L with [[Merge]]. Merges from left to right, first items get overridden by the next ones (last-in overrides).

    Parameter L

    to assign to

    Parameter Ls

    to assign

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=undefined) types of O to be replaced with ones of O1

    Returns

    [[Object]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = Assign<[1, 2, 3], [[2, 1]]> // [2, 1, 3]
    type test1 = Assign<[], [[1, 2, 3, 4], [2, 4, 6]]> // [2, 4, 6, 4]
    type test2 = Assign<[0, 0, 0, 0, 0], [[0, 1], [0, 2, 0, 4?]]> // [0, 2, 0, 0 | 4, 0]

type AtLeast

type AtLeast<L extends List, K extends Key = Keys<L>> = OAtLeast<
ObjectOf<L>,
`${K & number}` | K
> extends infer U
? U extends unknown
? _ListOf<U & {}>
: never
: never;
  • Make that at least one of the keys K are required in L at a time.

    Parameter L

    to make required

    Parameter K

    (?=keyof L) to choose fields

    Returns

    [[List]] [[Union]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.AtLeast<[1, 2, 3], 0> // [1, 2 | undefined, 3 | undefined]
    type test1 = L.AtLeast<[1, 2, 3], 0 | 1> // [1, 2 | undefined, 3 | undefined] | [1 | undefined, 2, 3 | undefined]
    type test2 = L.AtLeast<[1, 2, 3]>
    // | [1, 2, 3]
    // | [1, 2 | undefined, 3 | undefined]
    // | [1 | undefined, 2, 3 | undefined]
    // | [1 | undefined, 2 | undefined, 3]

type Compulsory

type Compulsory<L extends List, depth extends Depth = 'flat'> = Cast<
CompulsoryPart<L, depth>,
List
>;
  • Make that L's fields cannot be [[Nullable]] or [[Optional]] (it's like [[Required]] & [[NonNullable]] at once).

    Parameter L

    to make compulsory

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    * import {L} from 'ts-toolbelt'
    type test0 = L.Compulsory<[1, 2, 3?, 4?]> // [1, 2, 3, 4]
    type test1 = L.Compulsory<['a', 'b' | undefined, 'c', 'd', 'e' | null]> // ['a', 'b', 'c', 'd', 'e']

type CompulsoryKeys

type CompulsoryKeys<L extends List> = OCompulsoryKeys<ObjectOf<L>>;
  • Get the keys of L that are [[Compulsory]]

    (⚠️ needs --strictNullChecks enabled)

    Parameter L

    Returns

    [[Key]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.CompulsoryKeys<[1, 2, 3]> // {0: 1, 1: 2, 2: 3}

type Concat

type Concat<L extends List, L1 extends List> = [...L, ...L1];
  • Attach L1 at the end of L

    Parameter L

    to concat with

    Parameter L1

    to be attached

    Returns

    [[List]]

    Example 1

    import {L} from 'ts-toolbelt'
    type test0 = L.Concat<[1, 2], [3, 4]> // [1, 2, 3, 4]
    type test1 = L.Concat<[1, 2], [[3], 4]> // [1, 2, [3], 4]
    type test2 = L.Concat<[1, 2], number[]> // [1, 2, ...number[]]
    type test3 = L.Concat<readonly [1, 2], readonly [3]> // [1, 2, 3]

type Diff

type Diff<L extends List, L1 extends List, match extends Match = 'default'> = ListOf<
ODiff<ObjectOf<L>, ObjectOf<L1>, match>
>;
  • Get a [[List]] that is the difference between L & L1 (L's differences have priority over L1's if entries overlap) (If match = 'default', no type checks are done)

    Parameter L

    to check differences with

    Parameter L1

    to check differences against

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type Drop

type Drop<
L extends List,
N extends number,
way extends Way = '->'
> = L extends unknown ? (N extends unknown ? _Drop<L, N, way> : never) : never;
  • Remove N entries out of L

    Parameter L

    to remove from

    Parameter N

    to remove out

    Parameter way

    (?='->') from front: '->', from end: '<-'

    Returns

    [[List]]

    Example 1

    ```ts ```

type Either

type Either<L extends List, K extends Key, strict extends Boolean = 1> = OEither<
ObjectOf<L>,
`${K & number}` | K,
strict
> extends infer OE
? OE extends unknown
? _ListOf<OE & {}>
: never
: never;
  • Split L into a [[Union]] with K keys in such a way that none of the keys are ever present with one another within the different unions.

    Parameter L

    to split

    Parameter K

    to split with

    Parameter strict

    (?=1) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863

    Returns

    [[List]] [[Union]]

    Example 1

    ```ts ```

type Exclude

type Exclude<
L extends List,
L1 extends List,
match extends Match = 'default'
> = ListOf<OExclude<ObjectOf<L>, ObjectOf<L1>, match>>;
  • Exclude the entries of L1 out of L (If match = 'default', no type checks are done)

    Parameter L

    to remove from

    Parameter L1

    to remove out

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type ExcludeKeys

type ExcludeKeys<
L extends List,
L1 extends List,
match extends Match = 'default'
> = OExcludeKeys<ObjectOf<L>, ObjectOf<L1>, match>;
  • Exclude the keys of L1 out of the keys of L (If match = 'default', no type checks are done)

    Parameter L

    to remove the keys from

    Parameter L1

    to remove the keys out

    Parameter match

    (?='default') to change precision

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Extract

type Extract<L extends List, From extends number, To extends number> = Pick<
L,
KeySet<From, To>
>;
  • Pick a range of entries (portion) from L

    Parameter L

    to pick from

    Parameter From

    to start with

    Parameter To

    to end with

    Returns

    [[List]]

    Example 1

    ```ts ```

type Filter

type Filter<L extends List, M extends any, match extends Match = 'default'> = ListOf<
OFilter<ObjectOf<L>, M, match>
>;
  • Filter out of L the entries that match M

    Parameter L

    to remove from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type FilterKeys

type FilterKeys<
L extends List,
M extends any,
match extends Match = 'default'
> = OFilterKeys<ObjectOf<L>, M, match>;
  • Filter out the keys of L which entries match M

    Parameter L

    to remove from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Flatten

type Flatten<
L extends List,
strict extends Boolean = 1,
limit extends number = number
> = L extends unknown ? _Flatten<L, strict, limit> : never;
  • Remove all dimensions of L (10 max)

    Parameter L

    to un-nest

    Parameter strict

    (?=1) 0 to not preserve tuples

    Parameter limit

    (?=string) to stop un-nesting at

    Returns

    [[List]]

    Example 1

    ```ts ```

type Group

type Group<L extends List, N extends number> = L extends unknown
? N extends unknown
? _Group<L, N>
: never
: never;
  • Split L into sub-[[List]]s every N

    Parameter L

    to group

    Parameter N

    to split at

    Returns

    [[List]]

    Example 1

    ```ts ```

type Has

type Has<
L extends List,
K extends Key,
M extends any = any,
match extends Match = 'default'
> = OHas<ObjectOf<L>, `${K & number}` | K, M, match>;
  • Check whether L has a entry of key K that matches M

    Parameter L

    to be inspected

    Parameter K

    to choose entry

    Parameter M

    (?=any) to check entry type

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    ```ts ```

type HasPath

type HasPath<
L extends List,
Path extends List<Key>,
M extends any = any,
match extends Match = 'default'
> = OHasPath<ObjectOf<L>, Path, M, match>;
  • Check whether L has nested entries that match M

    Parameter L

    to be inspected

    Parameter Path

    to be followed

    Parameter M

    (?=any) to check entry type

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    ```ts ```

type Head

type Head<L extends List> = Length<L> extends 0 ? never : L[0];
  • Get the first entry of L

    Parameter L

    to extract from

    Returns

    [[Any]]

    Example 1

    ```ts ```

type Includes

type Includes<
L extends List,
M extends any,
match extends Match = 'default'
> = OIncludes<ObjectOf<L>, M, match>;
  • Check whether L has entries that match M

    Parameter L

    to be inspected

    Parameter M

    to check entry type

    Parameter match

    (?='default') to change precision

    Returns

    [[Boolean]]

    Example 1

    ```ts ```

type Intersect

type Intersect<
L extends List,
L1 extends List,
match extends Match = 'default'
> = ListOf<OIntersect<ObjectOf<L>, ObjectOf<L1>, match>>;
  • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

    Parameter L

    to check similarities with

    Parameter L1

    to check similarities against

    Returns

    [[List]]

    Example 1

    ```ts ```

type IntersectKeys

type IntersectKeys<
L extends List,
L1 extends List,
match extends Match = 'default'
> = OIntersectKeys<ObjectOf<L>, L1, match>;
  • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

    Parameter L

    to check similarities with

    Parameter L1

    to check similarities against

    Returns

    [[Key]]

    Example 1

    ```ts ```

type KeySet

type KeySet<From extends number, To extends number> = UnionOf<Range<From, To, '->'>>;
  • Create a set of keys

    Parameter From

    to start with

    Parameter To

    to end with

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Last

type Last<L extends List> = L[Length<Tail<L>>];
  • Get the last entry of L

    Parameter L

    to extract from

    Returns

    [[Any]]

    Example 1

    ```ts ```

type LastKey

type LastKey<L extends List> = Length<Tail<L>>;
  • Get the last index of L

    Parameter L

    to get from

    Returns

    number

    Example 1

    ```ts ```

type Length

type Length<L extends List> = L['length'];
  • Get the length of L

    Parameter L

    to get length

    Returns

    [[String]] or number

    Example 1

    ```ts ```

type List

type List<A = any> = ReadonlyArray<A>;
  • A [[List]]

    Parameter A

    its type

    Returns

    [[List]]

    Example 1

    type list0 = [1, 2, 3]
    type list1 = number[]

type Longest

type Longest<L extends List, L1 extends List> = L extends unknown
? L1 extends unknown
? {
0: L1;
1: L;
}[Has<keyof L, keyof L1>]
: never
: never;
  • Get the longest [[List]] of L & L1 (L has priority if both lengths are equal)

    Parameter L

    to compare length

    Parameter L1

    to compare length

    Returns

    L | L1

    Example 1

    ```ts ```

type Merge

type Merge<
L extends List,
L1 extends List,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = undefined
> = Cast<OMerge<L, L1, depth, ignore, fill>, List>;
  • Accurately merge the fields of L with the ones of L1. It is equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] fields will be handled gracefully.

    (⚠️ needs --strictNullChecks enabled)

    Parameter L

    to complete

    Parameter L1

    to copy from

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=undefined) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type MergeAll

type MergeAll<
L extends List,
Ls extends List<List>,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = undefined
> = Cast<OMergeAll<L, Ls, depth, ignore, fill>, List>;
  • [[Merge]] a list of [[List]]s into L. Merges from left to right, first items get completed by the next ones (last-in completes).

    Parameter L

    to start with

    Parameter Ls

    to merge

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=undefined) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type Modify

type Modify<L extends List, LMod extends List> = Cast<
{
[K in keyof LMod]: Replace<LMod[K], x, Exclude<At<L, K>, undefined>>;
},
List
>;
  • Modify L with LMod & the [[x]] placeholder

    Parameter L

    to copy from

    Parameter LMod

    to copy to

    Returns

    [[List]]

    Example 1

    ```ts ```

type NonNullable

type NonNullable<
L extends List,
K extends Key = Key,
depth extends Depth = 'flat'
> = Cast<NonNullablePart<L, `${K & number}` | K, depth>, List>;
  • Make some entries of L not nullable (deeply or not)

    Parameter L

    to make non nullable

    Parameter K

    (?=Key) to choose fields

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type NonNullableKeys

type NonNullableKeys<L extends List> = ONonNullableKeys<ObjectOf<L>>;
  • Get the keys of L that are non-nullable

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Nullable

type Nullable<L extends List, K extends Key = Key> = Cast<
Update<L, `${K & number}` | K, x | null | undefined>,
List
>;
  • Make some entries of L nullable (deeply or not)

    Parameter L

    to make nullable

    Parameter K

    (?=Key) to choose fields

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type NullableKeys

type NullableKeys<L extends List> = ONullableKeys<ObjectOf<L>>;
  • Get the keys of L that are nullable

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type ObjectOf

type ObjectOf<O extends List> = O extends unknown
? number extends Length<O>
? _Pick<O, number>
: _Omit<O, keyof any[]>
: never;
  • Transform a [[List]] into an [[Object]] equivalent

    Parameter L

    to transform

    Returns

    [[Object]]

    Example 1

    ```ts ```

type Omit

type Omit<L extends List, K extends Key> = L extends unknown ? _Omit<L, K> : never;
  • Remove out of L the entries of key K

    Parameter L

    to remove from

    Parameter K

    to chose entries

    Returns

    [[List]]

    Example 1

    ```ts ```

type Optional

type Optional<L extends List, depth extends Depth = 'flat'> = Cast<
OptionalPart<L, depth>,
List
>;
  • Make L optional (deeply or not)

    Parameter L

    to make optional

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type OptionalKeys

type OptionalKeys<L extends List> = OOptionalKeys<ObjectOf<L>>;
  • Get the keys of L that are optional

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Overwrite

type Overwrite<L extends List, L1 extends object> = Cast<OOverwrite<L, L1>, List>;
  • Update the entries of L with the ones of L1

    Parameter L

    to update

    Parameter L1

    to update with

    Returns

    [[Object]]

    Example 1

    ```ts ```

type Partial

type Partial<L extends List, depth extends Depth = 'flat'> = Cast<
OPartial<L, depth>,
List
>;
  • Make all fields of O optional (deeply or not)

    Parameter L

    to make optional

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    import {O} from 'ts-toolbelt'
    type L = [1, 2, 3, [4, [5]]]
    type test0 = O.Partial<L>
    type test1 = O.Partial<L, 'deep'>

type Patch

type Patch<
L extends List,
L1 extends List,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = never
> = Cast<OPatch<L, L1, depth, ignore, fill>, List>;
  • Complete the fields of L with the ones of L1. This is a version of [[Merge]] that does NOT handle optional fields, it only completes fields of O with the ones of O1 if they don't exist.

    (⚠️ needs --strictNullChecks enabled)

    Parameter L

    to complete

    Parameter L1

    to copy from

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=never) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type PatchAll

type PatchAll<
O extends List,
Ls extends List<List>,
depth extends Depth = 'flat',
ignore extends object = BuiltIn,
fill extends any = never
> = Cast<OPatchAll<O, Ls, depth, ignore, fill>, List>;
  • [[Patch]] a list of [[List]]s into L. Patches from left to right, first items get completed by the next ones (last-in completes).

    Parameter O

    to start with

    Parameter Os

    to patch

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Parameter ignore

    (?=BuiltIn) types not to merge

    Parameter fill

    (?=never) types of O to be replaced with ones of O1

    Returns

    [[List]]

    Example 1

    ```ts ```

type Path

type Path<L extends List, Path extends List<Key>> = OPath<L, Path>;
  • Get in L the type of nested properties

    Parameter L

    to be inspected

    Parameter Path

    to be followed

    Returns

    [[Any]]

    Example 1

    ```ts ```

type Paths

type Paths<L extends List> = OPaths<ObjectOf<L>>;
  • Get all the possible paths of L (⚠️ this won't work with circular-refs)

    Parameter L

    to be inspected

    Returns

    [[String]][]

    Example 1

    ```ts ```

type Pick

type Pick<L extends List, K extends Key> = L extends unknown ? _Pick<L, K> : never;
  • Extract out of L the entries of key K

    Parameter L

    to extract from

    Parameter K

    to chose entries

    Returns

    [[List]]

    Example 1

    ```ts ```

type Pop

type Pop<L extends List> = L extends
| readonly [...infer LBody, any]
| readonly [...infer LBody, any?]
? LBody
: L;
  • Remove the last element out of L

    Parameter L

    to remove from

    Returns

    [[List]]

    Example 1

    ```ts ```

type Prepend

type Prepend<L extends List, A extends any> = [A, ...L];
  • Add an element A at the beginning of L

    Parameter L

    to append to

    Parameter A

    to be added to

    Returns

    [[List]]

    Example 1

    ```ts ```

type Readonly

type Readonly<L extends List, depth extends Depth = 'flat'> = Cast<
ReadonlyPart<L, depth>,
List
>;
  • Make L readonly (deeply or not)

    Parameter L

    to make readonly

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type ReadonlyKeys

type ReadonlyKeys<L extends List> = OReadonlyKeys<ObjectOf<L>>;
  • Get the keys of L that are readonly

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Remove

type Remove<L extends List, From extends number, To extends number> = Omit<
L,
KeySet<From, To>
>;
  • Remove out of L a range of entries

    Parameter L

    to remove from

    Parameter From

    to start from

    Parameter To

    to end with

    Returns

    [[List]]

    Example 1

    ```ts ```

type Repeat

type Repeat<A extends any, N extends number, L extends List = []> = N extends unknown
? L extends unknown
? _Repeat<A, N, L>
: never
: never;
  • Fill a [[List]] with N times A

    Parameter A

    to fill with

    Parameter N

    to repeat it

    Parameter L

    (?=[]) to be filled

    Returns

    [[List]]

    Example 1

    ```ts ```

type Replace

type Replace<
L extends List,
M extends any,
A extends any,
match extends Match = 'default'
> = Cast<OReplace<L, M, A, match>, List>;
  • Update with A the entries of L that match M

    Parameter O

    to update

    Parameter M

    to select fields

    Parameter A

    to update with

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type Required

type Required<L extends List, depth extends Depth = 'flat'> = Cast<
RequiredPart<L, depth>,
List
>;
  • Make L required (deeply or not)

    Parameter L

    to make required

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type RequiredKeys

type RequiredKeys<L extends List> = ORequiredKeys<ObjectOf<L>>;
  • Get the keys of L that are readonly

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Reverse

type Reverse<L extends List> = L extends unknown ? _Reverse<L> : never;
  • Turn a [[List]] the other way around

    Parameter L

    to reverse

    Parameter LO

    (?=[]) to prepend to

    Returns

    [[List]]

    Example 1

    ```ts ```

type Select

type Select<L extends List, M extends any, match extends Match = 'default'> = ListOf<
OSelect<ObjectOf<L>, M, match>
>;
  • Extract the entries of L that match M

    Parameter L

    to extract from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[List]]

    Example 1

    ```ts ```

type SelectKeys

type SelectKeys<
L extends List,
M extends any,
match extends Match = 'default'
> = OSelectKeys<ObjectOf<L>, M, match>;
  • Get the keys of L which entries match M

    Parameter L

    to extract from

    Parameter M

    to select entries

    Parameter match

    (?='default') to change precision

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Shortest

type Shortest<L extends List, L1 extends List> = L extends unknown
? L1 extends unknown
? {
0: L1;
1: L;
}[Has<keyof L1, keyof L>]
: never
: never;
  • Get the shortest [[List]] of L & L1 (L has priority if both lengths are equal)

    Parameter L

    to compare length

    Parameter L1

    to compare length

    Returns

    L | L1

    Example 1

    ```ts ```

type Tail

type Tail<L extends List> = L extends readonly []
? L
: L extends readonly [any?, ...infer LTail]
? LTail
: L;
  • Remove the first item out of a [[List]]

    Parameter L

    Returns

    [[List]]

    Example 1

    ```ts ```

type Take

type Take<
L extends List,
N extends number,
way extends Way = '->'
> = L extends unknown ? (N extends unknown ? _Take<L, N, way> : never) : never;
  • Extract N entries out of L

    Parameter L

    to extract from

    Parameter N

    to extract out

    Parameter way

    (?='->') to extract from end

    Returns

    [[List]]

    Example 1

    ```ts ```

type Undefinable

type Undefinable<L extends List, K extends Key = Key> = Cast<
Update<L, `${K & number}` | K, x | undefined>,
List
>;
  • Make some entries of L not undefined (deeply or not)

    Parameter L

    to make non nullable

    Parameter K

    (?=Key) to choose fields

    Returns

    [[List]]

    Example 1

    ```ts ```

type UndefinableKeys

type UndefinableKeys<L extends List> = OUndefinableKeys<ObjectOf<L>>;
  • Get the keys of L that are undefined

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Unionize

type Unionize<L extends List, L1 extends List, K extends Key = Key> = {
[P in keyof L]: P extends K ? L[P] | At<L1, P> : L[P];
};
  • Make the fields of L union the ones of L1

    Parameter L

    to union from

    Parameter L1

    to union with

    Parameter K

    (?=Key) to do choose fields

    Returns

    [[List]]

    Example 1

    ```ts ```

type UnionOf

type UnionOf<L extends List> = L[number];
  • Transform a [[List]] into an [[Union]]

    Parameter L

    to transform

    Returns

    [[Any]]

    Example 1

    ```ts ```

type UnNest

type UnNest<L extends List, strict extends Boolean = 1> = L extends unknown
? _UnNest<L, strict>
: never;
  • Remove a dimension of L

    Parameter L

    to un-nest

    Parameter strict

    (?=1) 0 to not preserve tuples

    Returns

    [[List]]

    Example 1

    ```ts ```

type Update

type Update<L extends List, K extends Key, A extends any> = Cast<
OUpdate<L, `${K & number}` | K, A>,
List
>;
  • Update in L the entries of key K with A. Use the [[x]] placeholder to get the current field type.

    Parameter L

    to update

    Parameter K

    to chose fields

    Parameter A

    to update with

    Returns

    [[List]]

    Example 1

    ```ts ```

type Writable

type Writable<L extends List, depth extends Depth = 'flat'> = Cast<
WritablePart<L, depth>,
List
>;
  • Make L writable (deeply or not)

    Parameter L

    to make writable

    Parameter depth

    (?='flat') 'deep' to do it deeply

    Returns

    [[List]]

    Example 1

    ```ts ```

type WritableKeys

type WritableKeys<L extends List> = OWritableKeys<ObjectOf<L>>;
  • Get the keys of L that are writable

    Parameter L

    Returns

    [[Key]]

    Example 1

    ```ts ```

type Zip

type Zip<L extends List, L1 extends List> = L extends unknown
? L1 extends unknown
? _Zip<L, L1>
: never
: never;
  • Pair up the entries of L with L1

    Parameter L

    to pair up

    Parameter L1

    to pair up with

    Returns

    [[List]]

    Example 1

    ```ts ```

type ZipObj

type ZipObj<LKeys extends List<Key>, LFields extends List> = LKeys extends unknown
? LFields extends unknown
? _ZipObj<LKeys, LFields>
: never
: never;
  • Create an [[Object]] from [[List]]s of keys & fields

    Parameter LKeys

    its keys

    Parameter LFields

    its fields

    Returns

    [[Object]]

    Example 1

    ```ts ```

namespace M

module 'out/Misc/_api.d.ts' {}

type BuiltIn

type BuiltIn =
| Function
| Error
| Date
| {
readonly [Symbol.toStringTag]: string;
}
| RegExp
| Generator;

type Primitive

type Primitive = boolean | string | number | bigint | symbol | undefined | null;
  • All primitive types

namespace JSON

module 'out/Misc/JSON/_api.d.ts' {}

interface Array

interface List extends Array<Value> {}
  • A list of JSON [[Value]]s

interface Object

interface Object {}
  • An object of JSON [[Value]]s

index signature

[k: string]: Value;

    type Primitive

    type Primitive = string | number | boolean | null;
    • Basic JSON Value

    type Value

    type Value = Primitive | Object | List;
    • Any JSON data/value

    namespace Misc

    module 'out/Misc/_api.d.ts' {}

    type BuiltIn

    type BuiltIn =
    | Function
    | Error
    | Date
    | {
    readonly [Symbol.toStringTag]: string;
    }
    | RegExp
    | Generator;

    type Primitive

    type Primitive = boolean | string | number | bigint | symbol | undefined | null;
    • All primitive types

    namespace JSON

    module 'out/Misc/JSON/_api.d.ts' {}

    interface Array

    interface List extends Array<Value> {}
    • A list of JSON [[Value]]s

    interface Object

    interface Object {}
    • An object of JSON [[Value]]s

    index signature

    [k: string]: Value;

      type Primitive

      type Primitive = string | number | boolean | null;
      • Basic JSON Value

      type Value

      type Value = Primitive | Object | List;
      • Any JSON data/value

      namespace N

      module 'out/Number/_api.d.ts' {}

      type Absolute

      type Absolute<N extends number> = N extends unknown
      ? _Absolute<IterationOf<N>>[0]
      : never;
      • Get the absolute value of a [[Number]]

        Parameter N

        to absolute

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Absolute<'-20'> // '20'
        type test1 = N.Absolute<'-20', 's'> // '20'
        type test2 = N.Absolute<'-20', 'n'> // 20

      type Add

      type Add<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Add<IterationOf<N1>, IterationOf<N2>>[0]
      : never
      : never;
      • Add a [[Number]] to another one

        Parameter N1

        Left-hand side

        Parameter N2

        Right-hand side

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Add<'2', '10'> // '12'
        type test1 = N.Add<'0', '40'> // '40'
        type test2 = N.Add<'0', '40', 's'> // '40'
        type test3 = N.Add<'0', '40', 'n'> // 40
        type test4 = N.Add<'-20', '40', 's'> // '20'
        type test5 = N.Add<'-20', '40', 'n'> // 20

      type Greater

      type Greater<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Greater<IterationOf<N1>, IterationOf<N2>>
      : never
      : never;
      • Check if a [[Number]] is bigger than another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Greater<'7', '5'> // True
        type test1 = N.Greater<'5', '5'> // False
        type test2 = N.Greater<'5', '7'> // False

      type GreaterEq

      type GreaterEq<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _GreaterEq<IterationOf<N1>, IterationOf<N2>>
      : never
      : never;
      • Check if a [[Number]] is greater or equal to another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.GreaterEq<'7', '5'> // True
        type test1 = N.GreaterEq<'5', '5'> // True
        type test2 = N.GreaterEq<'5', '7'> // False

      type IsNegative

      type IsNegative<N extends number> = _IsNegative<IterationOf<N>>;
      • Check whether a [[Number]] is negative or not

        Parameter N

        to check

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.IsNegative<'0'> // False
        type test1 = N.IsNegative<'-7'> // True
        type test2 = N.IsNegative<'7'> // False

      type IsPositive

      type IsPositive<N extends number> = _IsPositive<IterationOf<N>>;
      • Check whether a [[Number]] is positive or not

        Parameter N

        to check

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.IsPositive<'0'> // False
        type test1 = N.IsPositive<'-7'> // False
        type test2 = N.IsPositive<'7'> // True

      type IsZero

      type IsZero<N extends number> = _IsZero<IterationOf<N>>;
      • Check whether a [[Number]] is null or not

        Parameter N

        to check

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.IsZero<'0'> // True
        type test1 = N.IsZero<'-7'> // False
        type test2 = N.IsZero<'7'> // False

      type Lower

      type Lower<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Lower<IterationOf<N1>, IterationOf<N2>>
      : never
      : never;
      • Check if a [[Number]] is lower than another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Lower<'7', '5'> // False
        type test1 = N.Lower<'5', '5'> // False
        type test2 = N.Lower<'5', '7'> // True

      type LowerEq

      type LowerEq<N1 extends number, N2 extends number> = GreaterEq<N2, N1>;
      • Check if a [[Number]] is lower or equal to another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.LowerEq<'7', '5'> // False
        type test1 = N.LowerEq<'5', '5'> // True
        type test2 = N.LowerEq<'5', '7'> // True

      type Negate

      type Negate<N extends number> = N extends unknown
      ? _Negate<IterationOf<N>>[0]
      : never;
      • Negate a [[Number]]

        Parameter N

        to negate

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Negate<'-10'> // '10'
        type test1 = N.Negate<'10'> // '-10'
        type test2 = N.Negate<'10', 's'> // '-10'
        type test3 = N.Negate<'10', 'n'> // -10
        type test4 = N.Negate<'-100'> // string

      type Range

      type Range<
      From extends number,
      To extends number,
      way extends Way = '->'
      > = From extends unknown
      ? To extends unknown
      ? _Range<From, To, way>
      : never
      : never;
      • Create a range of * *number**s

        Parameter From

        to start with

        Parameter To

        to end with

        Parameter way

        (?='->') to reverse it

        Returns

        string[] | number[] | boolean[]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Range<'-2', '1'> // ['-2', '-1', '0', '1']
        type test1 = N.Range<'-2', '1', '->'> // ['-2', '-1', '0', '1']
        type test2 = N.Range<'-2', '1', '<-'> // ['1', '0', '-1', '-2']

      type Sub

      type Sub<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Sub<IterationOf<N1>, IterationOf<N2>>[0]
      : never
      : never;
      • Subtract a [[Number]] from another one

        Parameter N1

        Left-hand side

        Parameter N2

        Right-hand side

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Sub<'2', '10'> // '-8'
        type test1 = N.Sub<'0', '40'> // '-40'
        type test2 = N.Sub<'0', '40', 's'> // '-40'
        type test3 = N.Sub<'0', '40', 'n'> // -40
        type test4 = N.Sub<'-20', '40', 's'> // string
        type test5 = N.Sub<'-20', '40', 'n'> // number

      namespace Number

      module 'out/Number/_api.d.ts' {}

      type Absolute

      type Absolute<N extends number> = N extends unknown
      ? _Absolute<IterationOf<N>>[0]
      : never;
      • Get the absolute value of a [[Number]]

        Parameter N

        to absolute

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Absolute<'-20'> // '20'
        type test1 = N.Absolute<'-20', 's'> // '20'
        type test2 = N.Absolute<'-20', 'n'> // 20

      type Add

      type Add<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Add<IterationOf<N1>, IterationOf<N2>>[0]
      : never
      : never;
      • Add a [[Number]] to another one

        Parameter N1

        Left-hand side

        Parameter N2

        Right-hand side

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Add<'2', '10'> // '12'
        type test1 = N.Add<'0', '40'> // '40'
        type test2 = N.Add<'0', '40', 's'> // '40'
        type test3 = N.Add<'0', '40', 'n'> // 40
        type test4 = N.Add<'-20', '40', 's'> // '20'
        type test5 = N.Add<'-20', '40', 'n'> // 20

      type Greater

      type Greater<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Greater<IterationOf<N1>, IterationOf<N2>>
      : never
      : never;
      • Check if a [[Number]] is bigger than another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Greater<'7', '5'> // True
        type test1 = N.Greater<'5', '5'> // False
        type test2 = N.Greater<'5', '7'> // False

      type GreaterEq

      type GreaterEq<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _GreaterEq<IterationOf<N1>, IterationOf<N2>>
      : never
      : never;
      • Check if a [[Number]] is greater or equal to another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.GreaterEq<'7', '5'> // True
        type test1 = N.GreaterEq<'5', '5'> // True
        type test2 = N.GreaterEq<'5', '7'> // False

      type IsNegative

      type IsNegative<N extends number> = _IsNegative<IterationOf<N>>;
      • Check whether a [[Number]] is negative or not

        Parameter N

        to check

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.IsNegative<'0'> // False
        type test1 = N.IsNegative<'-7'> // True
        type test2 = N.IsNegative<'7'> // False

      type IsPositive

      type IsPositive<N extends number> = _IsPositive<IterationOf<N>>;
      • Check whether a [[Number]] is positive or not

        Parameter N

        to check

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.IsPositive<'0'> // False
        type test1 = N.IsPositive<'-7'> // False
        type test2 = N.IsPositive<'7'> // True

      type IsZero

      type IsZero<N extends number> = _IsZero<IterationOf<N>>;
      • Check whether a [[Number]] is null or not

        Parameter N

        to check

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.IsZero<'0'> // True
        type test1 = N.IsZero<'-7'> // False
        type test2 = N.IsZero<'7'> // False

      type Lower

      type Lower<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Lower<IterationOf<N1>, IterationOf<N2>>
      : never
      : never;
      • Check if a [[Number]] is lower than another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Lower<'7', '5'> // False
        type test1 = N.Lower<'5', '5'> // False
        type test2 = N.Lower<'5', '7'> // True

      type LowerEq

      type LowerEq<N1 extends number, N2 extends number> = GreaterEq<N2, N1>;
      • Check if a [[Number]] is lower or equal to another one

        Parameter N1

        to compare

        Parameter N2

        to compare to

        Returns

        [[Boolean]]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.LowerEq<'7', '5'> // False
        type test1 = N.LowerEq<'5', '5'> // True
        type test2 = N.LowerEq<'5', '7'> // True

      type Negate

      type Negate<N extends number> = N extends unknown
      ? _Negate<IterationOf<N>>[0]
      : never;
      • Negate a [[Number]]

        Parameter N

        to negate

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Negate<'-10'> // '10'
        type test1 = N.Negate<'10'> // '-10'
        type test2 = N.Negate<'10', 's'> // '-10'
        type test3 = N.Negate<'10', 'n'> // -10
        type test4 = N.Negate<'-100'> // string

      type Range

      type Range<
      From extends number,
      To extends number,
      way extends Way = '->'
      > = From extends unknown
      ? To extends unknown
      ? _Range<From, To, way>
      : never
      : never;
      • Create a range of * *number**s

        Parameter From

        to start with

        Parameter To

        to end with

        Parameter way

        (?='->') to reverse it

        Returns

        string[] | number[] | boolean[]

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Range<'-2', '1'> // ['-2', '-1', '0', '1']
        type test1 = N.Range<'-2', '1', '->'> // ['-2', '-1', '0', '1']
        type test2 = N.Range<'-2', '1', '<-'> // ['1', '0', '-1', '-2']

      type Sub

      type Sub<N1 extends number, N2 extends number> = N1 extends unknown
      ? N2 extends unknown
      ? _Sub<IterationOf<N1>, IterationOf<N2>>[0]
      : never
      : never;
      • Subtract a [[Number]] from another one

        Parameter N1

        Left-hand side

        Parameter N2

        Right-hand side

        Returns

        string | number | boolean

        Example 1

        import {N} from 'ts-toolbelt'
        type test0 = N.Sub<'2', '10'> // '-8'
        type test1 = N.Sub<'0', '40'> // '-40'
        type test2 = N.Sub<'0', '40', 's'> // '-40'
        type test3 = N.Sub<'0', '40', 'n'> // -40
        type test4 = N.Sub<'-20', '40', 's'> // string
        type test5 = N.Sub<'-20', '40', 'n'> // number

      namespace O

      module 'out/Object/_api.d.ts' {}

      type Assign

      type Assign<
      O extends object,
      Os extends List<object>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = O extends unknown
      ? Os extends unknown
      ? _Assign<O, Os, depth, ignore, fill>
      : never
      : never;
      • Assign a list of [[Object]] into O with [[Merge]]. Merges from right to left, first items get overridden by the next ones (last-in overrides).

        Parameter O

        to assign to

        Parameter Os

        to assign

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type AtLeast

      type AtLeast<O extends object, K extends Key = Keys<O>> = O extends unknown
      ? _AtLeast<O, K>
      : never;
      • Make that at least one of the keys K are required in O at a time.

        Parameter O

        to make required

        Parameter K

        (?=keyof O) to choose fields

        Returns

        [[Object]] [[Union]]

        Example 1

        ```ts ```

      type Compulsory

      type Compulsory<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Compulsory<O, K, depth> : never;
      • Make that O's fields cannot be [[Nullable]] or [[Optional]] (it's like [[Required]] & [[NonNullable]] at once).

        Parameter O

        to make compulsory

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type CompulsoryKeys

      type CompulsoryKeys<O extends object> = O extends unknown
      ? _CompulsoryKeys<O>
      : never;
      • Get the keys of O that are [[Compulsory]]

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Diff

      type Diff<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = PatchFlat<Exclude<O, O1, match>, Exclude<O1, O, match>>;
      • Get an [[Object]] that is the difference between O & O1 (O's differences have priority over O1's if fields overlap) (If match = 'default', no type checks are done)

        Parameter O

        to check differences with

        Parameter O1

        to check differences against

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type Person0 = {
        name: string
        age: string
        }
        type Person1 = {
        name: string
        age: number | string
        nick: string
        }
        type test0 = O.Diff<Person0, Person1, 'default'> // {nick: string}
        type test1 = O.Diff<Person0, Person1, 'extends->'> // {nick: string; age: string | number}
        type test2 = O.Diff<Person0, Person1, '<-extends'> // {nick: string; age: string}
        type test3 = O.Diff<Person0, Person1, 'equals'> // {nick: string; age: string}

      type Either

      type Either<
      O extends object,
      K extends Key,
      strict extends Boolean = 1
      > = O extends unknown ? _Either<O, K, strict> : never;
      • Split O into a [[Union]] with K keys in such a way that none of the keys are ever present with one another within the different unions.

        Parameter O

        to split

        Parameter K

        to split with

        Parameter strict

        (?=1) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863

        Returns

        [[Object]] [[Union]]

        Example 1

        ```ts ```

      type Exclude

      type Exclude<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = Pick<O, ExcludeKeys<O, O1, match>>;
      • Exclude the fields of O1 out of O (If match = 'default', no type checks are done)

        Parameter O

        to remove from

        Parameter O1

        to remove out

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type ExcludeKeys

      type ExcludeKeys<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = {
      default: Exclude<Keys<O>, Keys<O1>>;
      'contains->': ExcludeMatch<O, O1, 'contains->'>;
      'extends->': ExcludeMatch<O, O1, 'extends->'>;
      '<-contains': ExcludeMatch<O, O1, '<-contains'>;
      '<-extends': ExcludeMatch<O, O1, '<-extends'>;
      equals: ExcludeMatch<O, O1, 'equals'>;
      }[match];
      • Exclude the keys of O1 out of the keys of O (If match = 'default', no type checks are done)

        Parameter O

        to remove the keys from

        Parameter O1

        to remove the keys out

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Filter

      type Filter<O extends object, M extends any, match extends Match = 'default'> = Pick<
      O,
      FilterKeys<O, M, match>
      >;
      • Filter out of O the fields that match M

        Parameter O

        to remove from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type FilterKeys

      type FilterKeys<
      O extends object,
      M extends any,
      match extends Match = 'default'
      > = O extends unknown ? _FilterKeys<O, M, match> : never;
      • Filter out the keys of O which fields match M

        Parameter O

        to remove from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Has

      type Has<
      O extends object,
      K extends Key,
      M extends any = any,
      match extends Match = 'default'
      > = Is<At<O, K>, M, match>;
      • Check whether O has a field of key K that matches M

        Parameter O

        to be inspected

        Parameter K

        to choose field

        Parameter M

        (?=any) to check field type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type HasPath

      type HasPath<
      O extends object,
      Path extends List<Key>,
      M extends any = any,
      match extends Match = 'default'
      > = Is<OPath<O, Path>, M, match>;
      • Check whether O has nested properties that match M

        Parameter O

        to be inspected

        Parameter Path

        to be followed

        Parameter M

        (?=any) to check field type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Includes

      type Includes<O extends object, M extends any, match extends Match = 'default'> = [
      SelectKeys<O, M, match>
      ] extends [never]
      ? 0
      : 1;
      • Check whether O has fields that match M

        Parameter O

        to be inspected

        Parameter M

        to check field type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Intersect

      type Intersect<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = Pick<O, IntersectKeys<O, O1, match>>;
      • Get the intersecting fields of O & O1 (If match = 'default', no type checks are done)

        Parameter O

        to check similarities with

        Parameter O1

        to check similarities against

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type IntersectKeys

      type IntersectKeys<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = {
      default: Keys<O> & Keys<O1>;
      'contains->': IntersectMatch<O, O1, 'contains->'>;
      'extends->': IntersectMatch<O, O1, 'extends->'>;
      '<-contains': IntersectMatch<O, O1, '<-contains'>;
      '<-extends': IntersectMatch<O, O1, '<-extends'>;
      equals: IntersectMatch<O, O1, 'equals'>;
      }[match];
      • Get the intersecting keys of O & O1 (If match = 'default', no type checks are done)

        Parameter O

        to check similarities with

        Parameter O1

        to check similarities against

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Invert

      type Invert<O extends Record<keyof O, Key>> = O extends unknown ? _Invert<O> : never;
      • Swaps the keys and values of an [[Object]] (if applicable)

        Parameter O

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        enum E {
        A = 'Av',
        B = 'Bv',
        C = 'Cv',
        D = 'Dv',
        X = 1
        }
        type O = {
        A: 'Av'
        B: 'Bv'
        C: 'Cv'
        D: 'Dv'
        X: 1
        }
        type test0 = O.Invert<typeof E>
        type test1 = O.Invert<O>

      type ListOf

      type ListOf<O extends object> = O extends unknown ? _ListOf<O> : never;
      • Transform an [[Object]] into a [[List]] (It will only pick numeric literal indexes)

        Parameter O

        to transform

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Merge

      type Merge<
      O extends object,
      O1 extends object,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = {
      flat: MergeFlat<O, O1, ignore, fill>;
      deep: MergeDeep<O, O1, ignore, fill>;
      }[depth];
      • Accurately merge the fields of O with the ones of O1. It is equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] fields will be handled gracefully.

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        to complete

        Parameter O1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type O = {
        name?: string
        age? : number
        zip? : string
        pay : {
        cvv?: number
        }
        }
        type O1 = {
        age : number
        zip?: number
        city: string
        pay : {
        cvv : number
        ccn?: string
        }
        }
        type test = O.Merge<O, O1, 'deep'>
        // {
        // name?: string;
        // age: number;
        // zip?: string | number;
        // pay: {
        // cvv: number;
        // ccn?: string;
        // };
        // city: string;
        // }

      type MergeAll

      type MergeAll<
      O extends object,
      Os extends List<object>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = O extends unknown
      ? Os extends unknown
      ? _MergeAll<O, Os, depth, ignore, fill>
      : never
      : never;
      • [[Merge]] a list of [[Object]]s into O. Merges from left to right, first items get completed by the next ones (last-in completes).

        Parameter O

        to start with

        Parameter Os

        to merge

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Modify

      type Modify<O extends object, OMod extends object> = {
      [K in keyof OMod]: Replace<OMod[K], x, Exclude<At<O, K>, undefined>>;
      } & {};
      • Modify O with OMod & the [[x]] placeholder

        Parameter O

        to copy from

        Parameter OMod

        to copy to

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NonNullable

      type NonNullable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _NonNullable<O, K, depth> : never;
      • Make some fields of O not nullable (deeply or not) (Optional fields will be left untouched & undefined)

        Parameter O

        to make non nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NonNullableKeys

      type NonNullableKeys<O extends object> = O extends unknown
      ? _NonNullableKeys<O>
      : never;
      • Get the keys of O that are non-nullable

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Nullable

      type Nullable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Nullable<O, K, depth> : never;
      • Make some fields of O nullable (deeply or not)

        Parameter O

        to make nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NullableKeys

      type NullableKeys<O extends object> = O extends unknown ? _NullableKeys<O> : never;
      • Get the keys of O that are nullable

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Object

      type Object = Record<Key, any>;
      • An [[Object]]

        Example 1

        type object0 = {a: "hello"}
        type string1 = {b: "world"}

      type Omit

      type Omit<O extends object, K extends Key> = O extends unknown ? _Omit<O, K> : never;
      • Remove out of O the fields of key K

        Parameter O

        to remove from

        Parameter K

        to chose fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Optional

      type Optional<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = {
      1: OptionalPart<O, depth>;
      0: PatchFlat<OptionalPart<Pick<O, K>, depth>, O>;
      }[Equals<Key, K>];
      • Make some fields of O optional (deeply or not)

        Parameter O

        to make optional

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type OptionalKeys

      type OptionalKeys<O extends object> = O extends unknown ? _OptionalKeys<O> : never;
      • Get the keys of O that are optional

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Overwrite

      type Overwrite<O extends object, O1 extends object> = {
      [K in keyof O]: K extends keyof O1 ? O1[K] : O[K];
      } & {};
      • Update the fields of O with the ones of O1 (only the existing fields will be updated)

        Parameter O

        to update

        Parameter O1

        to update with

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Partial

      type Partial<O extends object, depth extends Depth = 'flat'> = OptionalPart<
      O,
      depth
      >;
      • Make all fields of O optional (deeply or not)

        Parameter O

        to make optional

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type L = {a: {b: {c: 2}}, b: 1}
        type test0 = O.Partial<L>
        type test1 = O.Partial<L, 'deep'>

      type Patch

      type Patch<
      O extends object,
      O1 extends object,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = {
      flat: PatchFlat<O, O1, ignore, fill>;
      deep: PatchDeep<O, O1, ignore, fill>;
      }[depth];
      • Complete the fields of O with the ones of O1. This is a version of [[Merge]] that does NOT handle optional fields, it only completes fields of O with the ones of O1.

        Parameter O

        to complete

        Parameter O1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type O = {
        name?: string
        age? : number
        zip? : string
        pay : {
        cvv?: number
        }
        }
        type O1 = {
        age : number
        zip?: number
        city: string
        pay : {
        cvv : number
        ccn?: string
        }
        }
        type test = O.Patch<O, O1, 'deep'>
        // {
        // name?: string;
        // age?: number;
        // zip?: string | number;
        // pay: {
        // cvv?: number;
        // ccn?: string;
        // };
        // city: string;
        // }

      type PatchAll

      type PatchAll<
      O extends object,
      Os extends List<object>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = O extends unknown
      ? Os extends unknown
      ? _PatchAll<O, Os, depth, ignore, fill>
      : never
      : never;
      • [[Patch]] a list of [[Object]]s into O. Patches from left to right, first items get completed by the next ones (last-in completes).

        Parameter O

        to start with

        Parameter Os

        to patch

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Path

      type Path<O extends any, P extends List<Key>> = _Path<O & {}, P> extends infer X
      ? Cast<X, any>
      : never;
      • Get in O the type of nested properties

        Parameter O

        to be inspected

        Parameter Path

        to be followed

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Paths

      type Paths<O, P extends List = []> = _Paths<O, P> extends infer X
      ? Cast<X, List<Key>>
      : never;
      • Get all the possible paths of O (⚠️ this won't work with circular-refs)

        Parameter O

        to be inspected

        Returns

        [[String]][]

        Example 1

        ```ts ```

      type Pick

      type Pick<O extends object, K extends Key> = O extends unknown ? _Pick<O, K> : never;
      • Extract out of O the fields of key K

        Parameter O

        to extract from

        Parameter K

        to chose fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Readonly

      type Readonly<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Readonly<O, K, depth> : never;
      • Make some fields of O readonly (deeply or not)

        Parameter O

        to make readonly

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='default') to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type ReadonlyKeys

      type ReadonlyKeys<O extends object> = O extends unknown ? _ReadonlyKeys<O> : never;
      • Get the keys of O that are readonly

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Record

      type Record<
      K extends Key,
      A extends any = unknown,
      modx extends Modx = ['!', 'W']
      > = {
      '!': {
      R: {
      readonly [P in K]: A;
      };
      W: {
      [P in K]: A;
      };
      };
      '?': {
      R: {
      readonly [P in K]?: A;
      };
      W: {
      [P in K]?: A;
      };
      };
      }[modx[0]][modx[1]];
      • Create an object filled with A for the fields K

        Parameter K

        to choose fields

        Parameter A

        (?=unknown) to fill fields with

        Parameter modx

        (?=['!', 'W']) to set modifiers

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Replace

      type Replace<
      O extends object,
      M extends any,
      A extends any,
      match extends Match = 'default'
      > = O extends unknown ? _Replace<O, M, A, match> : never;
      • Update with A the fields of O that match M

        Parameter O

        to update

        Parameter M

        to select fields

        Parameter A

        to update with

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Required

      type Required<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Required<O, K, depth> : never;
      • Make some fields of O required (deeply or not)

        Parameter O

        to make required

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type RequiredKeys

      type RequiredKeys<O extends object> = O extends unknown ? _RequiredKeys<O> : never;
      • Get the keys of O that are required

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Select

      type Select<O extends object, M extends any, match extends Match = 'default'> = Pick<
      O,
      SelectKeys<O, M, match>
      >;
      • Extract the fields of O that match M

        Parameter O

        to extract from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type SelectKeys

      type SelectKeys<
      O extends object,
      M extends any,
      match extends Match = 'default'
      > = O extends unknown ? _SelectKeys<O, M, match> : never;
      • Get the keys of O which fields match M

        Parameter O

        to extract from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Undefinable

      type Undefinable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Undefinable<O, K, depth> : never;
      • Make some fields of O undefined (deeply or not)

        Parameter O

        to make undefinable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type UndefinableKeys

      type UndefinableKeys<O extends object> = O extends unknown
      ? _UndefinableKeys<O>
      : never;
      • Get the keys of O that are undefined (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Unionize

      type Unionize<O extends object, O1 extends object, K extends Key = Key> = {
      [P in keyof O]: P extends K ? O[P] | At<O1, P> : O[P];
      } & {};
      • Make the fields of O union the ones of O1

        Parameter O

        to union from

        Parameter O1

        to union with

        Parameter K

        (?=Key) to chose fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type UnionOf

      type UnionOf<O extends object> = O extends unknown ? _UnionOf<O> : never;
      • Transform an [[Object]] into an [[Union]]

        Parameter O

        to transform

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Update

      type Update<O extends object, K extends Key, A extends any> = {
      [P in keyof O]: P extends K ? Replace<A, x, O[P]> : O[P];
      } & {};
      • Update in O the fields of key K with A. Use the [[x]] placeholder to get the current field type.

        Parameter O

        to update

        Parameter K

        to chose fields

        Parameter A

        to update with

        Returns

        [[Object]]

        Example 1

        import {A, O} from 'ts-toolbelt'
        type User = {
        info: {
        name: string
        age: number
        payment: {}
        }
        id: number
        }
        type test0 = Update<User, 'id' | 'info', A.x | null>
        // {
        // info: {
        // name: string;
        // age: number;
        // payment: {};
        // } | null;
        // id: number | null;
        // }

      type Writable

      type Writable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Writable<O, K, depth> : never;
      • Make some fields of O writable (deeply or not)

        Parameter O

        to make writable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type WritableKeys

      type WritableKeys<O extends object> = O extends unknown ? _WritableKeys<O> : never;
      • Get the keys of O that are writable

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      namespace P

      module 'out/Object/P/_api.d.ts' {}

      type Merge

      type Merge<
      O extends object,
      Path extends List<Key>,
      O1 extends object,
      depth extends Depth = 'flat'
      > = Path extends unknown ? MergeAt<O, Path, O1, depth> : never;
      • Complete the fields of O at Path with the ones of O1

        Parameter O

        to complete

        Parameter Path

        to be followed

        Parameter O1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Omit

      type Omit<O extends object, Path extends List<Key>> = Path extends unknown
      ? OmitAt<O, Path>
      : never;
      • Remove out of O the fields at Path

        Parameter O

        to remove from

        Parameter Path

        to be followed

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Pick

      type Pick<O extends object, Path extends List<Key>> = Path extends unknown
      ? PickAt<O, Path>
      : never;
      • Extract out of O the fields at Path

        Parameter O

        to extract from

        Parameter Path

        to be followed

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Readonly

      type Readonly<
      O extends object,
      Path extends List<Key>,
      depth extends Depth = 'flat'
      > = Path extends unknown ? ReadonlyAt<O, Path, depth> : never;
      • Make some fields of O readonly at Path (deeply or not)

        Parameter O

        to make readonly

        Parameter Path

        to be followed

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Record

      type Record<Path extends List<Key>, A, modx extends Modx = ['!', 'W']> = {
      '!': {
      R: Record_RR<Path, A>;
      W: Record_RW<Path, A>;
      };
      '?': {
      R: Record_OR<Path, A>;
      W: Record_OW<Path, A>;
      };
      }[modx[0]][modx[1]];
      • Create an object filled with A for the fields at the end of Path

        Parameter Path

        to choose fields

        Parameter A

        to fill fields with

        Parameter modx

        (?=['!', 'W']) to set modifiers

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Update

      type Update<
      O extends object,
      Path extends List<Key>,
      A extends any
      > = Path extends unknown ? UpdateAt<O, Path, A> : never;
      • Update in O the fields at Path with A

        Parameter O

        to update

        Parameter Path

        to be followed

        Parameter A

        to update with

        Returns

        [[Object]]

        Example 1

        ```ts ```

      namespace Object

      module 'out/Object/_api.d.ts' {}

      type Assign

      type Assign<
      O extends object,
      Os extends List<object>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = O extends unknown
      ? Os extends unknown
      ? _Assign<O, Os, depth, ignore, fill>
      : never
      : never;
      • Assign a list of [[Object]] into O with [[Merge]]. Merges from right to left, first items get overridden by the next ones (last-in overrides).

        Parameter O

        to assign to

        Parameter Os

        to assign

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type AtLeast

      type AtLeast<O extends object, K extends Key = Keys<O>> = O extends unknown
      ? _AtLeast<O, K>
      : never;
      • Make that at least one of the keys K are required in O at a time.

        Parameter O

        to make required

        Parameter K

        (?=keyof O) to choose fields

        Returns

        [[Object]] [[Union]]

        Example 1

        ```ts ```

      type Compulsory

      type Compulsory<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Compulsory<O, K, depth> : never;
      • Make that O's fields cannot be [[Nullable]] or [[Optional]] (it's like [[Required]] & [[NonNullable]] at once).

        Parameter O

        to make compulsory

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type CompulsoryKeys

      type CompulsoryKeys<O extends object> = O extends unknown
      ? _CompulsoryKeys<O>
      : never;
      • Get the keys of O that are [[Compulsory]]

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Diff

      type Diff<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = PatchFlat<Exclude<O, O1, match>, Exclude<O1, O, match>>;
      • Get an [[Object]] that is the difference between O & O1 (O's differences have priority over O1's if fields overlap) (If match = 'default', no type checks are done)

        Parameter O

        to check differences with

        Parameter O1

        to check differences against

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type Person0 = {
        name: string
        age: string
        }
        type Person1 = {
        name: string
        age: number | string
        nick: string
        }
        type test0 = O.Diff<Person0, Person1, 'default'> // {nick: string}
        type test1 = O.Diff<Person0, Person1, 'extends->'> // {nick: string; age: string | number}
        type test2 = O.Diff<Person0, Person1, '<-extends'> // {nick: string; age: string}
        type test3 = O.Diff<Person0, Person1, 'equals'> // {nick: string; age: string}

      type Either

      type Either<
      O extends object,
      K extends Key,
      strict extends Boolean = 1
      > = O extends unknown ? _Either<O, K, strict> : never;
      • Split O into a [[Union]] with K keys in such a way that none of the keys are ever present with one another within the different unions.

        Parameter O

        to split

        Parameter K

        to split with

        Parameter strict

        (?=1) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863

        Returns

        [[Object]] [[Union]]

        Example 1

        ```ts ```

      type Exclude

      type Exclude<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = Pick<O, ExcludeKeys<O, O1, match>>;
      • Exclude the fields of O1 out of O (If match = 'default', no type checks are done)

        Parameter O

        to remove from

        Parameter O1

        to remove out

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type ExcludeKeys

      type ExcludeKeys<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = {
      default: Exclude<Keys<O>, Keys<O1>>;
      'contains->': ExcludeMatch<O, O1, 'contains->'>;
      'extends->': ExcludeMatch<O, O1, 'extends->'>;
      '<-contains': ExcludeMatch<O, O1, '<-contains'>;
      '<-extends': ExcludeMatch<O, O1, '<-extends'>;
      equals: ExcludeMatch<O, O1, 'equals'>;
      }[match];
      • Exclude the keys of O1 out of the keys of O (If match = 'default', no type checks are done)

        Parameter O

        to remove the keys from

        Parameter O1

        to remove the keys out

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Filter

      type Filter<O extends object, M extends any, match extends Match = 'default'> = Pick<
      O,
      FilterKeys<O, M, match>
      >;
      • Filter out of O the fields that match M

        Parameter O

        to remove from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type FilterKeys

      type FilterKeys<
      O extends object,
      M extends any,
      match extends Match = 'default'
      > = O extends unknown ? _FilterKeys<O, M, match> : never;
      • Filter out the keys of O which fields match M

        Parameter O

        to remove from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Has

      type Has<
      O extends object,
      K extends Key,
      M extends any = any,
      match extends Match = 'default'
      > = Is<At<O, K>, M, match>;
      • Check whether O has a field of key K that matches M

        Parameter O

        to be inspected

        Parameter K

        to choose field

        Parameter M

        (?=any) to check field type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type HasPath

      type HasPath<
      O extends object,
      Path extends List<Key>,
      M extends any = any,
      match extends Match = 'default'
      > = Is<OPath<O, Path>, M, match>;
      • Check whether O has nested properties that match M

        Parameter O

        to be inspected

        Parameter Path

        to be followed

        Parameter M

        (?=any) to check field type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Includes

      type Includes<O extends object, M extends any, match extends Match = 'default'> = [
      SelectKeys<O, M, match>
      ] extends [never]
      ? 0
      : 1;
      • Check whether O has fields that match M

        Parameter O

        to be inspected

        Parameter M

        to check field type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Intersect

      type Intersect<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = Pick<O, IntersectKeys<O, O1, match>>;
      • Get the intersecting fields of O & O1 (If match = 'default', no type checks are done)

        Parameter O

        to check similarities with

        Parameter O1

        to check similarities against

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type IntersectKeys

      type IntersectKeys<
      O extends object,
      O1 extends object,
      match extends Match = 'default'
      > = {
      default: Keys<O> & Keys<O1>;
      'contains->': IntersectMatch<O, O1, 'contains->'>;
      'extends->': IntersectMatch<O, O1, 'extends->'>;
      '<-contains': IntersectMatch<O, O1, '<-contains'>;
      '<-extends': IntersectMatch<O, O1, '<-extends'>;
      equals: IntersectMatch<O, O1, 'equals'>;
      }[match];
      • Get the intersecting keys of O & O1 (If match = 'default', no type checks are done)

        Parameter O

        to check similarities with

        Parameter O1

        to check similarities against

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Invert

      type Invert<O extends Record<keyof O, Key>> = O extends unknown ? _Invert<O> : never;
      • Swaps the keys and values of an [[Object]] (if applicable)

        Parameter O

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        enum E {
        A = 'Av',
        B = 'Bv',
        C = 'Cv',
        D = 'Dv',
        X = 1
        }
        type O = {
        A: 'Av'
        B: 'Bv'
        C: 'Cv'
        D: 'Dv'
        X: 1
        }
        type test0 = O.Invert<typeof E>
        type test1 = O.Invert<O>

      type ListOf

      type ListOf<O extends object> = O extends unknown ? _ListOf<O> : never;
      • Transform an [[Object]] into a [[List]] (It will only pick numeric literal indexes)

        Parameter O

        to transform

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Merge

      type Merge<
      O extends object,
      O1 extends object,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = {
      flat: MergeFlat<O, O1, ignore, fill>;
      deep: MergeDeep<O, O1, ignore, fill>;
      }[depth];
      • Accurately merge the fields of O with the ones of O1. It is equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] fields will be handled gracefully.

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        to complete

        Parameter O1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type O = {
        name?: string
        age? : number
        zip? : string
        pay : {
        cvv?: number
        }
        }
        type O1 = {
        age : number
        zip?: number
        city: string
        pay : {
        cvv : number
        ccn?: string
        }
        }
        type test = O.Merge<O, O1, 'deep'>
        // {
        // name?: string;
        // age: number;
        // zip?: string | number;
        // pay: {
        // cvv: number;
        // ccn?: string;
        // };
        // city: string;
        // }

      type MergeAll

      type MergeAll<
      O extends object,
      Os extends List<object>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = O extends unknown
      ? Os extends unknown
      ? _MergeAll<O, Os, depth, ignore, fill>
      : never
      : never;
      • [[Merge]] a list of [[Object]]s into O. Merges from left to right, first items get completed by the next ones (last-in completes).

        Parameter O

        to start with

        Parameter Os

        to merge

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Modify

      type Modify<O extends object, OMod extends object> = {
      [K in keyof OMod]: Replace<OMod[K], x, Exclude<At<O, K>, undefined>>;
      } & {};
      • Modify O with OMod & the [[x]] placeholder

        Parameter O

        to copy from

        Parameter OMod

        to copy to

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NonNullable

      type NonNullable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _NonNullable<O, K, depth> : never;
      • Make some fields of O not nullable (deeply or not) (Optional fields will be left untouched & undefined)

        Parameter O

        to make non nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NonNullableKeys

      type NonNullableKeys<O extends object> = O extends unknown
      ? _NonNullableKeys<O>
      : never;
      • Get the keys of O that are non-nullable

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Nullable

      type Nullable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Nullable<O, K, depth> : never;
      • Make some fields of O nullable (deeply or not)

        Parameter O

        to make nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NullableKeys

      type NullableKeys<O extends object> = O extends unknown ? _NullableKeys<O> : never;
      • Get the keys of O that are nullable

        (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Object

      type Object = Record<Key, any>;
      • An [[Object]]

        Example 1

        type object0 = {a: "hello"}
        type string1 = {b: "world"}

      type Omit

      type Omit<O extends object, K extends Key> = O extends unknown ? _Omit<O, K> : never;
      • Remove out of O the fields of key K

        Parameter O

        to remove from

        Parameter K

        to chose fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Optional

      type Optional<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = {
      1: OptionalPart<O, depth>;
      0: PatchFlat<OptionalPart<Pick<O, K>, depth>, O>;
      }[Equals<Key, K>];
      • Make some fields of O optional (deeply or not)

        Parameter O

        to make optional

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type OptionalKeys

      type OptionalKeys<O extends object> = O extends unknown ? _OptionalKeys<O> : never;
      • Get the keys of O that are optional

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Overwrite

      type Overwrite<O extends object, O1 extends object> = {
      [K in keyof O]: K extends keyof O1 ? O1[K] : O[K];
      } & {};
      • Update the fields of O with the ones of O1 (only the existing fields will be updated)

        Parameter O

        to update

        Parameter O1

        to update with

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Partial

      type Partial<O extends object, depth extends Depth = 'flat'> = OptionalPart<
      O,
      depth
      >;
      • Make all fields of O optional (deeply or not)

        Parameter O

        to make optional

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type L = {a: {b: {c: 2}}, b: 1}
        type test0 = O.Partial<L>
        type test1 = O.Partial<L, 'deep'>

      type Patch

      type Patch<
      O extends object,
      O1 extends object,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = {
      flat: PatchFlat<O, O1, ignore, fill>;
      deep: PatchDeep<O, O1, ignore, fill>;
      }[depth];
      • Complete the fields of O with the ones of O1. This is a version of [[Merge]] that does NOT handle optional fields, it only completes fields of O with the ones of O1.

        Parameter O

        to complete

        Parameter O1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        import {O} from 'ts-toolbelt'
        type O = {
        name?: string
        age? : number
        zip? : string
        pay : {
        cvv?: number
        }
        }
        type O1 = {
        age : number
        zip?: number
        city: string
        pay : {
        cvv : number
        ccn?: string
        }
        }
        type test = O.Patch<O, O1, 'deep'>
        // {
        // name?: string;
        // age?: number;
        // zip?: string | number;
        // pay: {
        // cvv?: number;
        // ccn?: string;
        // };
        // city: string;
        // }

      type PatchAll

      type PatchAll<
      O extends object,
      Os extends List<object>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = O extends unknown
      ? Os extends unknown
      ? _PatchAll<O, Os, depth, ignore, fill>
      : never
      : never;
      • [[Patch]] a list of [[Object]]s into O. Patches from left to right, first items get completed by the next ones (last-in completes).

        Parameter O

        to start with

        Parameter Os

        to patch

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Path

      type Path<O extends any, P extends List<Key>> = _Path<O & {}, P> extends infer X
      ? Cast<X, any>
      : never;
      • Get in O the type of nested properties

        Parameter O

        to be inspected

        Parameter Path

        to be followed

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Paths

      type Paths<O, P extends List = []> = _Paths<O, P> extends infer X
      ? Cast<X, List<Key>>
      : never;
      • Get all the possible paths of O (⚠️ this won't work with circular-refs)

        Parameter O

        to be inspected

        Returns

        [[String]][]

        Example 1

        ```ts ```

      type Pick

      type Pick<O extends object, K extends Key> = O extends unknown ? _Pick<O, K> : never;
      • Extract out of O the fields of key K

        Parameter O

        to extract from

        Parameter K

        to chose fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Readonly

      type Readonly<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Readonly<O, K, depth> : never;
      • Make some fields of O readonly (deeply or not)

        Parameter O

        to make readonly

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='default') to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type ReadonlyKeys

      type ReadonlyKeys<O extends object> = O extends unknown ? _ReadonlyKeys<O> : never;
      • Get the keys of O that are readonly

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Record

      type Record<
      K extends Key,
      A extends any = unknown,
      modx extends Modx = ['!', 'W']
      > = {
      '!': {
      R: {
      readonly [P in K]: A;
      };
      W: {
      [P in K]: A;
      };
      };
      '?': {
      R: {
      readonly [P in K]?: A;
      };
      W: {
      [P in K]?: A;
      };
      };
      }[modx[0]][modx[1]];
      • Create an object filled with A for the fields K

        Parameter K

        to choose fields

        Parameter A

        (?=unknown) to fill fields with

        Parameter modx

        (?=['!', 'W']) to set modifiers

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Replace

      type Replace<
      O extends object,
      M extends any,
      A extends any,
      match extends Match = 'default'
      > = O extends unknown ? _Replace<O, M, A, match> : never;
      • Update with A the fields of O that match M

        Parameter O

        to update

        Parameter M

        to select fields

        Parameter A

        to update with

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Required

      type Required<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Required<O, K, depth> : never;
      • Make some fields of O required (deeply or not)

        Parameter O

        to make required

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type RequiredKeys

      type RequiredKeys<O extends object> = O extends unknown ? _RequiredKeys<O> : never;
      • Get the keys of O that are required

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Select

      type Select<O extends object, M extends any, match extends Match = 'default'> = Pick<
      O,
      SelectKeys<O, M, match>
      >;
      • Extract the fields of O that match M

        Parameter O

        to extract from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type SelectKeys

      type SelectKeys<
      O extends object,
      M extends any,
      match extends Match = 'default'
      > = O extends unknown ? _SelectKeys<O, M, match> : never;
      • Get the keys of O which fields match M

        Parameter O

        to extract from

        Parameter M

        to select fields

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Undefinable

      type Undefinable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Undefinable<O, K, depth> : never;
      • Make some fields of O undefined (deeply or not)

        Parameter O

        to make undefinable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type UndefinableKeys

      type UndefinableKeys<O extends object> = O extends unknown
      ? _UndefinableKeys<O>
      : never;
      • Get the keys of O that are undefined (⚠️ needs --strictNullChecks enabled)

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Unionize

      type Unionize<O extends object, O1 extends object, K extends Key = Key> = {
      [P in keyof O]: P extends K ? O[P] | At<O1, P> : O[P];
      } & {};
      • Make the fields of O union the ones of O1

        Parameter O

        to union from

        Parameter O1

        to union with

        Parameter K

        (?=Key) to chose fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type UnionOf

      type UnionOf<O extends object> = O extends unknown ? _UnionOf<O> : never;
      • Transform an [[Object]] into an [[Union]]

        Parameter O

        to transform

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Update

      type Update<O extends object, K extends Key, A extends any> = {
      [P in keyof O]: P extends K ? Replace<A, x, O[P]> : O[P];
      } & {};
      • Update in O the fields of key K with A. Use the [[x]] placeholder to get the current field type.

        Parameter O

        to update

        Parameter K

        to chose fields

        Parameter A

        to update with

        Returns

        [[Object]]

        Example 1

        import {A, O} from 'ts-toolbelt'
        type User = {
        info: {
        name: string
        age: number
        payment: {}
        }
        id: number
        }
        type test0 = Update<User, 'id' | 'info', A.x | null>
        // {
        // info: {
        // name: string;
        // age: number;
        // payment: {};
        // } | null;
        // id: number | null;
        // }

      type Writable

      type Writable<
      O extends object,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = O extends unknown ? _Writable<O, K, depth> : never;
      • Make some fields of O writable (deeply or not)

        Parameter O

        to make writable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type WritableKeys

      type WritableKeys<O extends object> = O extends unknown ? _WritableKeys<O> : never;
      • Get the keys of O that are writable

        Parameter O

        Returns

        [[Key]]

        Example 1

        ```ts ```

      namespace P

      module 'out/Object/P/_api.d.ts' {}

      type Merge

      type Merge<
      O extends object,
      Path extends List<Key>,
      O1 extends object,
      depth extends Depth = 'flat'
      > = Path extends unknown ? MergeAt<O, Path, O1, depth> : never;
      • Complete the fields of O at Path with the ones of O1

        Parameter O

        to complete

        Parameter Path

        to be followed

        Parameter O1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Omit

      type Omit<O extends object, Path extends List<Key>> = Path extends unknown
      ? OmitAt<O, Path>
      : never;
      • Remove out of O the fields at Path

        Parameter O

        to remove from

        Parameter Path

        to be followed

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Pick

      type Pick<O extends object, Path extends List<Key>> = Path extends unknown
      ? PickAt<O, Path>
      : never;
      • Extract out of O the fields at Path

        Parameter O

        to extract from

        Parameter Path

        to be followed

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Readonly

      type Readonly<
      O extends object,
      Path extends List<Key>,
      depth extends Depth = 'flat'
      > = Path extends unknown ? ReadonlyAt<O, Path, depth> : never;
      • Make some fields of O readonly at Path (deeply or not)

        Parameter O

        to make readonly

        Parameter Path

        to be followed

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Record

      type Record<Path extends List<Key>, A, modx extends Modx = ['!', 'W']> = {
      '!': {
      R: Record_RR<Path, A>;
      W: Record_RW<Path, A>;
      };
      '?': {
      R: Record_OR<Path, A>;
      W: Record_OW<Path, A>;
      };
      }[modx[0]][modx[1]];
      • Create an object filled with A for the fields at the end of Path

        Parameter Path

        to choose fields

        Parameter A

        to fill fields with

        Parameter modx

        (?=['!', 'W']) to set modifiers

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Update

      type Update<
      O extends object,
      Path extends List<Key>,
      A extends any
      > = Path extends unknown ? UpdateAt<O, Path, A> : never;
      • Update in O the fields at Path with A

        Parameter O

        to update

        Parameter Path

        to be followed

        Parameter A

        to update with

        Returns

        [[Object]]

        Example 1

        ```ts ```

      namespace S

      module 'out/String/_api.d.ts' {}

      type At

      type At<S extends string, K extends number> = AAt<Split<S, ''>, K>;
      • Get the character at position K

        Parameter S

        Parameter K

      type Join

      type Join<T extends List<Literal>, D extends string = ''> = _Join<
      T,
      D
      > extends infer X
      ? Cast<X, string>
      : never;
      • Concat many literals together

        Parameter T

        to concat

        Parameter D

        to delimit

      type Length

      type Length<S extends string> = LLength<Split<S, ''>>;
      • Get the length of a string

        Parameter S

      type Replace

      type Replace<S extends string, R extends Literal, W extends Literal> = _Replace<
      S,
      R,
      W
      > extends infer X
      ? Cast<X, string>
      : never;
      • Replace R with W in S

        Parameter S

        Parameter R

        Parameter W

      type Split

      type Split<S extends string, D extends string = ''> = _Split<S, D> extends infer X
      ? Cast<X, string[]>
      : never;
      • Split S by D into a [[List]]

        Parameter S

        to split up

        Parameter D

        to split at

      namespace String

      module 'out/String/_api.d.ts' {}

      type At

      type At<S extends string, K extends number> = AAt<Split<S, ''>, K>;
      • Get the character at position K

        Parameter S

        Parameter K

      type Join

      type Join<T extends List<Literal>, D extends string = ''> = _Join<
      T,
      D
      > extends infer X
      ? Cast<X, string>
      : never;
      • Concat many literals together

        Parameter T

        to concat

        Parameter D

        to delimit

      type Length

      type Length<S extends string> = LLength<Split<S, ''>>;
      • Get the length of a string

        Parameter S

      type Replace

      type Replace<S extends string, R extends Literal, W extends Literal> = _Replace<
      S,
      R,
      W
      > extends infer X
      ? Cast<X, string>
      : never;
      • Replace R with W in S

        Parameter S

        Parameter R

        Parameter W

      type Split

      type Split<S extends string, D extends string = ''> = _Split<S, D> extends infer X
      ? Cast<X, string[]>
      : never;
      • Split S by D into a [[List]]

        Parameter S

        to split up

        Parameter D

        to split at

      namespace T

      module 'out/List/_api.d.ts' {}

      type Append

      type Append<L extends List, A extends any> = [...L, A];
      • Add an element A at the end of L.

        Parameter L

        to append to

        Parameter A

        to be added to

        Returns

        [[List]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
        type test1 = L.Append<[], 'a'> // ['a']
        type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
        type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]

      type Assign

      type Assign<
      L extends List,
      Ls extends List<List>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = Cast<OAssign<L, Ls, depth, ignore, fill>, List>;
      • Assign a list of [[List]] into L with [[Merge]]. Merges from left to right, first items get overridden by the next ones (last-in overrides).

        Parameter L

        to assign to

        Parameter Ls

        to assign

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = Assign<[1, 2, 3], [[2, 1]]> // [2, 1, 3]
        type test1 = Assign<[], [[1, 2, 3, 4], [2, 4, 6]]> // [2, 4, 6, 4]
        type test2 = Assign<[0, 0, 0, 0, 0], [[0, 1], [0, 2, 0, 4?]]> // [0, 2, 0, 0 | 4, 0]

      type AtLeast

      type AtLeast<L extends List, K extends Key = Keys<L>> = OAtLeast<
      ObjectOf<L>,
      `${K & number}` | K
      > extends infer U
      ? U extends unknown
      ? _ListOf<U & {}>
      : never
      : never;
      • Make that at least one of the keys K are required in L at a time.

        Parameter L

        to make required

        Parameter K

        (?=keyof L) to choose fields

        Returns

        [[List]] [[Union]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.AtLeast<[1, 2, 3], 0> // [1, 2 | undefined, 3 | undefined]
        type test1 = L.AtLeast<[1, 2, 3], 0 | 1> // [1, 2 | undefined, 3 | undefined] | [1 | undefined, 2, 3 | undefined]
        type test2 = L.AtLeast<[1, 2, 3]>
        // | [1, 2, 3]
        // | [1, 2 | undefined, 3 | undefined]
        // | [1 | undefined, 2, 3 | undefined]
        // | [1 | undefined, 2 | undefined, 3]

      type Compulsory

      type Compulsory<L extends List, depth extends Depth = 'flat'> = Cast<
      CompulsoryPart<L, depth>,
      List
      >;
      • Make that L's fields cannot be [[Nullable]] or [[Optional]] (it's like [[Required]] & [[NonNullable]] at once).

        Parameter L

        to make compulsory

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        * import {L} from 'ts-toolbelt'
        type test0 = L.Compulsory<[1, 2, 3?, 4?]> // [1, 2, 3, 4]
        type test1 = L.Compulsory<['a', 'b' | undefined, 'c', 'd', 'e' | null]> // ['a', 'b', 'c', 'd', 'e']

      type CompulsoryKeys

      type CompulsoryKeys<L extends List> = OCompulsoryKeys<ObjectOf<L>>;
      • Get the keys of L that are [[Compulsory]]

        (⚠️ needs --strictNullChecks enabled)

        Parameter L

        Returns

        [[Key]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.CompulsoryKeys<[1, 2, 3]> // {0: 1, 1: 2, 2: 3}

      type Concat

      type Concat<L extends List, L1 extends List> = [...L, ...L1];
      • Attach L1 at the end of L

        Parameter L

        to concat with

        Parameter L1

        to be attached

        Returns

        [[List]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.Concat<[1, 2], [3, 4]> // [1, 2, 3, 4]
        type test1 = L.Concat<[1, 2], [[3], 4]> // [1, 2, [3], 4]
        type test2 = L.Concat<[1, 2], number[]> // [1, 2, ...number[]]
        type test3 = L.Concat<readonly [1, 2], readonly [3]> // [1, 2, 3]

      type Diff

      type Diff<L extends List, L1 extends List, match extends Match = 'default'> = ListOf<
      ODiff<ObjectOf<L>, ObjectOf<L1>, match>
      >;
      • Get a [[List]] that is the difference between L & L1 (L's differences have priority over L1's if entries overlap) (If match = 'default', no type checks are done)

        Parameter L

        to check differences with

        Parameter L1

        to check differences against

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Drop

      type Drop<
      L extends List,
      N extends number,
      way extends Way = '->'
      > = L extends unknown ? (N extends unknown ? _Drop<L, N, way> : never) : never;
      • Remove N entries out of L

        Parameter L

        to remove from

        Parameter N

        to remove out

        Parameter way

        (?='->') from front: '->', from end: '<-'

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Either

      type Either<L extends List, K extends Key, strict extends Boolean = 1> = OEither<
      ObjectOf<L>,
      `${K & number}` | K,
      strict
      > extends infer OE
      ? OE extends unknown
      ? _ListOf<OE & {}>
      : never
      : never;
      • Split L into a [[Union]] with K keys in such a way that none of the keys are ever present with one another within the different unions.

        Parameter L

        to split

        Parameter K

        to split with

        Parameter strict

        (?=1) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863

        Returns

        [[List]] [[Union]]

        Example 1

        ```ts ```

      type Exclude

      type Exclude<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = ListOf<OExclude<ObjectOf<L>, ObjectOf<L1>, match>>;
      • Exclude the entries of L1 out of L (If match = 'default', no type checks are done)

        Parameter L

        to remove from

        Parameter L1

        to remove out

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type ExcludeKeys

      type ExcludeKeys<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = OExcludeKeys<ObjectOf<L>, ObjectOf<L1>, match>;
      • Exclude the keys of L1 out of the keys of L (If match = 'default', no type checks are done)

        Parameter L

        to remove the keys from

        Parameter L1

        to remove the keys out

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Extract

      type Extract<L extends List, From extends number, To extends number> = Pick<
      L,
      KeySet<From, To>
      >;
      • Pick a range of entries (portion) from L

        Parameter L

        to pick from

        Parameter From

        to start with

        Parameter To

        to end with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Filter

      type Filter<L extends List, M extends any, match extends Match = 'default'> = ListOf<
      OFilter<ObjectOf<L>, M, match>
      >;
      • Filter out of L the entries that match M

        Parameter L

        to remove from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type FilterKeys

      type FilterKeys<
      L extends List,
      M extends any,
      match extends Match = 'default'
      > = OFilterKeys<ObjectOf<L>, M, match>;
      • Filter out the keys of L which entries match M

        Parameter L

        to remove from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Flatten

      type Flatten<
      L extends List,
      strict extends Boolean = 1,
      limit extends number = number
      > = L extends unknown ? _Flatten<L, strict, limit> : never;
      • Remove all dimensions of L (10 max)

        Parameter L

        to un-nest

        Parameter strict

        (?=1) 0 to not preserve tuples

        Parameter limit

        (?=string) to stop un-nesting at

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Group

      type Group<L extends List, N extends number> = L extends unknown
      ? N extends unknown
      ? _Group<L, N>
      : never
      : never;
      • Split L into sub-[[List]]s every N

        Parameter L

        to group

        Parameter N

        to split at

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Has

      type Has<
      L extends List,
      K extends Key,
      M extends any = any,
      match extends Match = 'default'
      > = OHas<ObjectOf<L>, `${K & number}` | K, M, match>;
      • Check whether L has a entry of key K that matches M

        Parameter L

        to be inspected

        Parameter K

        to choose entry

        Parameter M

        (?=any) to check entry type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type HasPath

      type HasPath<
      L extends List,
      Path extends List<Key>,
      M extends any = any,
      match extends Match = 'default'
      > = OHasPath<ObjectOf<L>, Path, M, match>;
      • Check whether L has nested entries that match M

        Parameter L

        to be inspected

        Parameter Path

        to be followed

        Parameter M

        (?=any) to check entry type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Head

      type Head<L extends List> = Length<L> extends 0 ? never : L[0];
      • Get the first entry of L

        Parameter L

        to extract from

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Includes

      type Includes<
      L extends List,
      M extends any,
      match extends Match = 'default'
      > = OIncludes<ObjectOf<L>, M, match>;
      • Check whether L has entries that match M

        Parameter L

        to be inspected

        Parameter M

        to check entry type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Intersect

      type Intersect<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = ListOf<OIntersect<ObjectOf<L>, ObjectOf<L1>, match>>;
      • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

        Parameter L

        to check similarities with

        Parameter L1

        to check similarities against

        Returns

        [[List]]

        Example 1

        ```ts ```

      type IntersectKeys

      type IntersectKeys<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = OIntersectKeys<ObjectOf<L>, L1, match>;
      • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

        Parameter L

        to check similarities with

        Parameter L1

        to check similarities against

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type KeySet

      type KeySet<From extends number, To extends number> = UnionOf<Range<From, To, '->'>>;
      • Create a set of keys

        Parameter From

        to start with

        Parameter To

        to end with

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Last

      type Last<L extends List> = L[Length<Tail<L>>];
      • Get the last entry of L

        Parameter L

        to extract from

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type LastKey

      type LastKey<L extends List> = Length<Tail<L>>;
      • Get the last index of L

        Parameter L

        to get from

        Returns

        number

        Example 1

        ```ts ```

      type Length

      type Length<L extends List> = L['length'];
      • Get the length of L

        Parameter L

        to get length

        Returns

        [[String]] or number

        Example 1

        ```ts ```

      type List

      type List<A = any> = ReadonlyArray<A>;
      • A [[List]]

        Parameter A

        its type

        Returns

        [[List]]

        Example 1

        type list0 = [1, 2, 3]
        type list1 = number[]

      type Longest

      type Longest<L extends List, L1 extends List> = L extends unknown
      ? L1 extends unknown
      ? {
      0: L1;
      1: L;
      }[Has<keyof L, keyof L1>]
      : never
      : never;
      • Get the longest [[List]] of L & L1 (L has priority if both lengths are equal)

        Parameter L

        to compare length

        Parameter L1

        to compare length

        Returns

        L | L1

        Example 1

        ```ts ```

      type Merge

      type Merge<
      L extends List,
      L1 extends List,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = Cast<OMerge<L, L1, depth, ignore, fill>, List>;
      • Accurately merge the fields of L with the ones of L1. It is equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] fields will be handled gracefully.

        (⚠️ needs --strictNullChecks enabled)

        Parameter L

        to complete

        Parameter L1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type MergeAll

      type MergeAll<
      L extends List,
      Ls extends List<List>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = Cast<OMergeAll<L, Ls, depth, ignore, fill>, List>;
      • [[Merge]] a list of [[List]]s into L. Merges from left to right, first items get completed by the next ones (last-in completes).

        Parameter L

        to start with

        Parameter Ls

        to merge

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Modify

      type Modify<L extends List, LMod extends List> = Cast<
      {
      [K in keyof LMod]: Replace<LMod[K], x, Exclude<At<L, K>, undefined>>;
      },
      List
      >;
      • Modify L with LMod & the [[x]] placeholder

        Parameter L

        to copy from

        Parameter LMod

        to copy to

        Returns

        [[List]]

        Example 1

        ```ts ```

      type NonNullable

      type NonNullable<
      L extends List,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = Cast<NonNullablePart<L, `${K & number}` | K, depth>, List>;
      • Make some entries of L not nullable (deeply or not)

        Parameter L

        to make non nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type NonNullableKeys

      type NonNullableKeys<L extends List> = ONonNullableKeys<ObjectOf<L>>;
      • Get the keys of L that are non-nullable

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Nullable

      type Nullable<L extends List, K extends Key = Key> = Cast<
      Update<L, `${K & number}` | K, x | null | undefined>,
      List
      >;
      • Make some entries of L nullable (deeply or not)

        Parameter L

        to make nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type NullableKeys

      type NullableKeys<L extends List> = ONullableKeys<ObjectOf<L>>;
      • Get the keys of L that are nullable

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type ObjectOf

      type ObjectOf<O extends List> = O extends unknown
      ? number extends Length<O>
      ? _Pick<O, number>
      : _Omit<O, keyof any[]>
      : never;
      • Transform a [[List]] into an [[Object]] equivalent

        Parameter L

        to transform

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Omit

      type Omit<L extends List, K extends Key> = L extends unknown ? _Omit<L, K> : never;
      • Remove out of L the entries of key K

        Parameter L

        to remove from

        Parameter K

        to chose entries

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Optional

      type Optional<L extends List, depth extends Depth = 'flat'> = Cast<
      OptionalPart<L, depth>,
      List
      >;
      • Make L optional (deeply or not)

        Parameter L

        to make optional

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type OptionalKeys

      type OptionalKeys<L extends List> = OOptionalKeys<ObjectOf<L>>;
      • Get the keys of L that are optional

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Overwrite

      type Overwrite<L extends List, L1 extends object> = Cast<OOverwrite<L, L1>, List>;
      • Update the entries of L with the ones of L1

        Parameter L

        to update

        Parameter L1

        to update with

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Partial

      type Partial<L extends List, depth extends Depth = 'flat'> = Cast<
      OPartial<L, depth>,
      List
      >;
      • Make all fields of O optional (deeply or not)

        Parameter L

        to make optional

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        import {O} from 'ts-toolbelt'
        type L = [1, 2, 3, [4, [5]]]
        type test0 = O.Partial<L>
        type test1 = O.Partial<L, 'deep'>

      type Patch

      type Patch<
      L extends List,
      L1 extends List,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = Cast<OPatch<L, L1, depth, ignore, fill>, List>;
      • Complete the fields of L with the ones of L1. This is a version of [[Merge]] that does NOT handle optional fields, it only completes fields of O with the ones of O1 if they don't exist.

        (⚠️ needs --strictNullChecks enabled)

        Parameter L

        to complete

        Parameter L1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type PatchAll

      type PatchAll<
      O extends List,
      Ls extends List<List>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = Cast<OPatchAll<O, Ls, depth, ignore, fill>, List>;
      • [[Patch]] a list of [[List]]s into L. Patches from left to right, first items get completed by the next ones (last-in completes).

        Parameter O

        to start with

        Parameter Os

        to patch

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Path

      type Path<L extends List, Path extends List<Key>> = OPath<L, Path>;
      • Get in L the type of nested properties

        Parameter L

        to be inspected

        Parameter Path

        to be followed

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Paths

      type Paths<L extends List> = OPaths<ObjectOf<L>>;
      • Get all the possible paths of L (⚠️ this won't work with circular-refs)

        Parameter L

        to be inspected

        Returns

        [[String]][]

        Example 1

        ```ts ```

      type Pick

      type Pick<L extends List, K extends Key> = L extends unknown ? _Pick<L, K> : never;
      • Extract out of L the entries of key K

        Parameter L

        to extract from

        Parameter K

        to chose entries

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Pop

      type Pop<L extends List> = L extends
      | readonly [...infer LBody, any]
      | readonly [...infer LBody, any?]
      ? LBody
      : L;
      • Remove the last element out of L

        Parameter L

        to remove from

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Prepend

      type Prepend<L extends List, A extends any> = [A, ...L];
      • Add an element A at the beginning of L

        Parameter L

        to append to

        Parameter A

        to be added to

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Readonly

      type Readonly<L extends List, depth extends Depth = 'flat'> = Cast<
      ReadonlyPart<L, depth>,
      List
      >;
      • Make L readonly (deeply or not)

        Parameter L

        to make readonly

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type ReadonlyKeys

      type ReadonlyKeys<L extends List> = OReadonlyKeys<ObjectOf<L>>;
      • Get the keys of L that are readonly

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Remove

      type Remove<L extends List, From extends number, To extends number> = Omit<
      L,
      KeySet<From, To>
      >;
      • Remove out of L a range of entries

        Parameter L

        to remove from

        Parameter From

        to start from

        Parameter To

        to end with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Repeat

      type Repeat<A extends any, N extends number, L extends List = []> = N extends unknown
      ? L extends unknown
      ? _Repeat<A, N, L>
      : never
      : never;
      • Fill a [[List]] with N times A

        Parameter A

        to fill with

        Parameter N

        to repeat it

        Parameter L

        (?=[]) to be filled

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Replace

      type Replace<
      L extends List,
      M extends any,
      A extends any,
      match extends Match = 'default'
      > = Cast<OReplace<L, M, A, match>, List>;
      • Update with A the entries of L that match M

        Parameter O

        to update

        Parameter M

        to select fields

        Parameter A

        to update with

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Required

      type Required<L extends List, depth extends Depth = 'flat'> = Cast<
      RequiredPart<L, depth>,
      List
      >;
      • Make L required (deeply or not)

        Parameter L

        to make required

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type RequiredKeys

      type RequiredKeys<L extends List> = ORequiredKeys<ObjectOf<L>>;
      • Get the keys of L that are readonly

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Reverse

      type Reverse<L extends List> = L extends unknown ? _Reverse<L> : never;
      • Turn a [[List]] the other way around

        Parameter L

        to reverse

        Parameter LO

        (?=[]) to prepend to

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Select

      type Select<L extends List, M extends any, match extends Match = 'default'> = ListOf<
      OSelect<ObjectOf<L>, M, match>
      >;
      • Extract the entries of L that match M

        Parameter L

        to extract from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type SelectKeys

      type SelectKeys<
      L extends List,
      M extends any,
      match extends Match = 'default'
      > = OSelectKeys<ObjectOf<L>, M, match>;
      • Get the keys of L which entries match M

        Parameter L

        to extract from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Shortest

      type Shortest<L extends List, L1 extends List> = L extends unknown
      ? L1 extends unknown
      ? {
      0: L1;
      1: L;
      }[Has<keyof L1, keyof L>]
      : never
      : never;
      • Get the shortest [[List]] of L & L1 (L has priority if both lengths are equal)

        Parameter L

        to compare length

        Parameter L1

        to compare length

        Returns

        L | L1

        Example 1

        ```ts ```

      type Tail

      type Tail<L extends List> = L extends readonly []
      ? L
      : L extends readonly [any?, ...infer LTail]
      ? LTail
      : L;
      • Remove the first item out of a [[List]]

        Parameter L

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Take

      type Take<
      L extends List,
      N extends number,
      way extends Way = '->'
      > = L extends unknown ? (N extends unknown ? _Take<L, N, way> : never) : never;
      • Extract N entries out of L

        Parameter L

        to extract from

        Parameter N

        to extract out

        Parameter way

        (?='->') to extract from end

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Undefinable

      type Undefinable<L extends List, K extends Key = Key> = Cast<
      Update<L, `${K & number}` | K, x | undefined>,
      List
      >;
      • Make some entries of L not undefined (deeply or not)

        Parameter L

        to make non nullable

        Parameter K

        (?=Key) to choose fields

        Returns

        [[List]]

        Example 1

        ```ts ```

      type UndefinableKeys

      type UndefinableKeys<L extends List> = OUndefinableKeys<ObjectOf<L>>;
      • Get the keys of L that are undefined

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Unionize

      type Unionize<L extends List, L1 extends List, K extends Key = Key> = {
      [P in keyof L]: P extends K ? L[P] | At<L1, P> : L[P];
      };
      • Make the fields of L union the ones of L1

        Parameter L

        to union from

        Parameter L1

        to union with

        Parameter K

        (?=Key) to do choose fields

        Returns

        [[List]]

        Example 1

        ```ts ```

      type UnionOf

      type UnionOf<L extends List> = L[number];
      • Transform a [[List]] into an [[Union]]

        Parameter L

        to transform

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type UnNest

      type UnNest<L extends List, strict extends Boolean = 1> = L extends unknown
      ? _UnNest<L, strict>
      : never;
      • Remove a dimension of L

        Parameter L

        to un-nest

        Parameter strict

        (?=1) 0 to not preserve tuples

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Update

      type Update<L extends List, K extends Key, A extends any> = Cast<
      OUpdate<L, `${K & number}` | K, A>,
      List
      >;
      • Update in L the entries of key K with A. Use the [[x]] placeholder to get the current field type.

        Parameter L

        to update

        Parameter K

        to chose fields

        Parameter A

        to update with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Writable

      type Writable<L extends List, depth extends Depth = 'flat'> = Cast<
      WritablePart<L, depth>,
      List
      >;
      • Make L writable (deeply or not)

        Parameter L

        to make writable

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type WritableKeys

      type WritableKeys<L extends List> = OWritableKeys<ObjectOf<L>>;
      • Get the keys of L that are writable

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Zip

      type Zip<L extends List, L1 extends List> = L extends unknown
      ? L1 extends unknown
      ? _Zip<L, L1>
      : never
      : never;
      • Pair up the entries of L with L1

        Parameter L

        to pair up

        Parameter L1

        to pair up with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type ZipObj

      type ZipObj<LKeys extends List<Key>, LFields extends List> = LKeys extends unknown
      ? LFields extends unknown
      ? _ZipObj<LKeys, LFields>
      : never
      : never;
      • Create an [[Object]] from [[List]]s of keys & fields

        Parameter LKeys

        its keys

        Parameter LFields

        its fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      namespace Test

      module 'out/Test.d.ts' {}
      • Test should pass

      function check

      check: <Type, Expect, Outcome extends Boolean>(
      debug?: Type
      ) => Equals<Equals<Type, Expect>, Outcome>;
      • Check or test the validity of a type

        Parameter debug

        to debug with parameter hints (ctrl+p, ctrl+shift+space)

        Example 1

        // see in `tst` folder

      function checks

      checks: (checks: 1[]) => void;
      • Validates a batch of [[check]]

        Parameter checks

        a batch of [[check]]

        Example 1

        // see in `tst` folder

      type Fail

      type Fail = 0;
      • Test should fail

      type Pass

      type Pass = 1;
      • Test should pass

      namespace Tuple

      module 'out/List/_api.d.ts' {}

      type Append

      type Append<L extends List, A extends any> = [...L, A];
      • Add an element A at the end of L.

        Parameter L

        to append to

        Parameter A

        to be added to

        Returns

        [[List]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
        type test1 = L.Append<[], 'a'> // ['a']
        type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
        type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]

      type Assign

      type Assign<
      L extends List,
      Ls extends List<List>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = Cast<OAssign<L, Ls, depth, ignore, fill>, List>;
      • Assign a list of [[List]] into L with [[Merge]]. Merges from left to right, first items get overridden by the next ones (last-in overrides).

        Parameter L

        to assign to

        Parameter Ls

        to assign

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[Object]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = Assign<[1, 2, 3], [[2, 1]]> // [2, 1, 3]
        type test1 = Assign<[], [[1, 2, 3, 4], [2, 4, 6]]> // [2, 4, 6, 4]
        type test2 = Assign<[0, 0, 0, 0, 0], [[0, 1], [0, 2, 0, 4?]]> // [0, 2, 0, 0 | 4, 0]

      type AtLeast

      type AtLeast<L extends List, K extends Key = Keys<L>> = OAtLeast<
      ObjectOf<L>,
      `${K & number}` | K
      > extends infer U
      ? U extends unknown
      ? _ListOf<U & {}>
      : never
      : never;
      • Make that at least one of the keys K are required in L at a time.

        Parameter L

        to make required

        Parameter K

        (?=keyof L) to choose fields

        Returns

        [[List]] [[Union]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.AtLeast<[1, 2, 3], 0> // [1, 2 | undefined, 3 | undefined]
        type test1 = L.AtLeast<[1, 2, 3], 0 | 1> // [1, 2 | undefined, 3 | undefined] | [1 | undefined, 2, 3 | undefined]
        type test2 = L.AtLeast<[1, 2, 3]>
        // | [1, 2, 3]
        // | [1, 2 | undefined, 3 | undefined]
        // | [1 | undefined, 2, 3 | undefined]
        // | [1 | undefined, 2 | undefined, 3]

      type Compulsory

      type Compulsory<L extends List, depth extends Depth = 'flat'> = Cast<
      CompulsoryPart<L, depth>,
      List
      >;
      • Make that L's fields cannot be [[Nullable]] or [[Optional]] (it's like [[Required]] & [[NonNullable]] at once).

        Parameter L

        to make compulsory

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        * import {L} from 'ts-toolbelt'
        type test0 = L.Compulsory<[1, 2, 3?, 4?]> // [1, 2, 3, 4]
        type test1 = L.Compulsory<['a', 'b' | undefined, 'c', 'd', 'e' | null]> // ['a', 'b', 'c', 'd', 'e']

      type CompulsoryKeys

      type CompulsoryKeys<L extends List> = OCompulsoryKeys<ObjectOf<L>>;
      • Get the keys of L that are [[Compulsory]]

        (⚠️ needs --strictNullChecks enabled)

        Parameter L

        Returns

        [[Key]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.CompulsoryKeys<[1, 2, 3]> // {0: 1, 1: 2, 2: 3}

      type Concat

      type Concat<L extends List, L1 extends List> = [...L, ...L1];
      • Attach L1 at the end of L

        Parameter L

        to concat with

        Parameter L1

        to be attached

        Returns

        [[List]]

        Example 1

        import {L} from 'ts-toolbelt'
        type test0 = L.Concat<[1, 2], [3, 4]> // [1, 2, 3, 4]
        type test1 = L.Concat<[1, 2], [[3], 4]> // [1, 2, [3], 4]
        type test2 = L.Concat<[1, 2], number[]> // [1, 2, ...number[]]
        type test3 = L.Concat<readonly [1, 2], readonly [3]> // [1, 2, 3]

      type Diff

      type Diff<L extends List, L1 extends List, match extends Match = 'default'> = ListOf<
      ODiff<ObjectOf<L>, ObjectOf<L1>, match>
      >;
      • Get a [[List]] that is the difference between L & L1 (L's differences have priority over L1's if entries overlap) (If match = 'default', no type checks are done)

        Parameter L

        to check differences with

        Parameter L1

        to check differences against

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Drop

      type Drop<
      L extends List,
      N extends number,
      way extends Way = '->'
      > = L extends unknown ? (N extends unknown ? _Drop<L, N, way> : never) : never;
      • Remove N entries out of L

        Parameter L

        to remove from

        Parameter N

        to remove out

        Parameter way

        (?='->') from front: '->', from end: '<-'

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Either

      type Either<L extends List, K extends Key, strict extends Boolean = 1> = OEither<
      ObjectOf<L>,
      `${K & number}` | K,
      strict
      > extends infer OE
      ? OE extends unknown
      ? _ListOf<OE & {}>
      : never
      : never;
      • Split L into a [[Union]] with K keys in such a way that none of the keys are ever present with one another within the different unions.

        Parameter L

        to split

        Parameter K

        to split with

        Parameter strict

        (?=1) to force excess property checks https://github.com/microsoft/TypeScript/issues/20863

        Returns

        [[List]] [[Union]]

        Example 1

        ```ts ```

      type Exclude

      type Exclude<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = ListOf<OExclude<ObjectOf<L>, ObjectOf<L1>, match>>;
      • Exclude the entries of L1 out of L (If match = 'default', no type checks are done)

        Parameter L

        to remove from

        Parameter L1

        to remove out

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type ExcludeKeys

      type ExcludeKeys<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = OExcludeKeys<ObjectOf<L>, ObjectOf<L1>, match>;
      • Exclude the keys of L1 out of the keys of L (If match = 'default', no type checks are done)

        Parameter L

        to remove the keys from

        Parameter L1

        to remove the keys out

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Extract

      type Extract<L extends List, From extends number, To extends number> = Pick<
      L,
      KeySet<From, To>
      >;
      • Pick a range of entries (portion) from L

        Parameter L

        to pick from

        Parameter From

        to start with

        Parameter To

        to end with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Filter

      type Filter<L extends List, M extends any, match extends Match = 'default'> = ListOf<
      OFilter<ObjectOf<L>, M, match>
      >;
      • Filter out of L the entries that match M

        Parameter L

        to remove from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type FilterKeys

      type FilterKeys<
      L extends List,
      M extends any,
      match extends Match = 'default'
      > = OFilterKeys<ObjectOf<L>, M, match>;
      • Filter out the keys of L which entries match M

        Parameter L

        to remove from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Flatten

      type Flatten<
      L extends List,
      strict extends Boolean = 1,
      limit extends number = number
      > = L extends unknown ? _Flatten<L, strict, limit> : never;
      • Remove all dimensions of L (10 max)

        Parameter L

        to un-nest

        Parameter strict

        (?=1) 0 to not preserve tuples

        Parameter limit

        (?=string) to stop un-nesting at

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Group

      type Group<L extends List, N extends number> = L extends unknown
      ? N extends unknown
      ? _Group<L, N>
      : never
      : never;
      • Split L into sub-[[List]]s every N

        Parameter L

        to group

        Parameter N

        to split at

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Has

      type Has<
      L extends List,
      K extends Key,
      M extends any = any,
      match extends Match = 'default'
      > = OHas<ObjectOf<L>, `${K & number}` | K, M, match>;
      • Check whether L has a entry of key K that matches M

        Parameter L

        to be inspected

        Parameter K

        to choose entry

        Parameter M

        (?=any) to check entry type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type HasPath

      type HasPath<
      L extends List,
      Path extends List<Key>,
      M extends any = any,
      match extends Match = 'default'
      > = OHasPath<ObjectOf<L>, Path, M, match>;
      • Check whether L has nested entries that match M

        Parameter L

        to be inspected

        Parameter Path

        to be followed

        Parameter M

        (?=any) to check entry type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Head

      type Head<L extends List> = Length<L> extends 0 ? never : L[0];
      • Get the first entry of L

        Parameter L

        to extract from

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Includes

      type Includes<
      L extends List,
      M extends any,
      match extends Match = 'default'
      > = OIncludes<ObjectOf<L>, M, match>;
      • Check whether L has entries that match M

        Parameter L

        to be inspected

        Parameter M

        to check entry type

        Parameter match

        (?='default') to change precision

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Intersect

      type Intersect<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = ListOf<OIntersect<ObjectOf<L>, ObjectOf<L1>, match>>;
      • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

        Parameter L

        to check similarities with

        Parameter L1

        to check similarities against

        Returns

        [[List]]

        Example 1

        ```ts ```

      type IntersectKeys

      type IntersectKeys<
      L extends List,
      L1 extends List,
      match extends Match = 'default'
      > = OIntersectKeys<ObjectOf<L>, L1, match>;
      • Get the intersecting entries of L & L1 (If match = 'default', no type checks are done)

        Parameter L

        to check similarities with

        Parameter L1

        to check similarities against

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type KeySet

      type KeySet<From extends number, To extends number> = UnionOf<Range<From, To, '->'>>;
      • Create a set of keys

        Parameter From

        to start with

        Parameter To

        to end with

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Last

      type Last<L extends List> = L[Length<Tail<L>>];
      • Get the last entry of L

        Parameter L

        to extract from

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type LastKey

      type LastKey<L extends List> = Length<Tail<L>>;
      • Get the last index of L

        Parameter L

        to get from

        Returns

        number

        Example 1

        ```ts ```

      type Length

      type Length<L extends List> = L['length'];
      • Get the length of L

        Parameter L

        to get length

        Returns

        [[String]] or number

        Example 1

        ```ts ```

      type List

      type List<A = any> = ReadonlyArray<A>;
      • A [[List]]

        Parameter A

        its type

        Returns

        [[List]]

        Example 1

        type list0 = [1, 2, 3]
        type list1 = number[]

      type Longest

      type Longest<L extends List, L1 extends List> = L extends unknown
      ? L1 extends unknown
      ? {
      0: L1;
      1: L;
      }[Has<keyof L, keyof L1>]
      : never
      : never;
      • Get the longest [[List]] of L & L1 (L has priority if both lengths are equal)

        Parameter L

        to compare length

        Parameter L1

        to compare length

        Returns

        L | L1

        Example 1

        ```ts ```

      type Merge

      type Merge<
      L extends List,
      L1 extends List,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = Cast<OMerge<L, L1, depth, ignore, fill>, List>;
      • Accurately merge the fields of L with the ones of L1. It is equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] fields will be handled gracefully.

        (⚠️ needs --strictNullChecks enabled)

        Parameter L

        to complete

        Parameter L1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type MergeAll

      type MergeAll<
      L extends List,
      Ls extends List<List>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = undefined
      > = Cast<OMergeAll<L, Ls, depth, ignore, fill>, List>;
      • [[Merge]] a list of [[List]]s into L. Merges from left to right, first items get completed by the next ones (last-in completes).

        Parameter L

        to start with

        Parameter Ls

        to merge

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=undefined) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Modify

      type Modify<L extends List, LMod extends List> = Cast<
      {
      [K in keyof LMod]: Replace<LMod[K], x, Exclude<At<L, K>, undefined>>;
      },
      List
      >;
      • Modify L with LMod & the [[x]] placeholder

        Parameter L

        to copy from

        Parameter LMod

        to copy to

        Returns

        [[List]]

        Example 1

        ```ts ```

      type NonNullable

      type NonNullable<
      L extends List,
      K extends Key = Key,
      depth extends Depth = 'flat'
      > = Cast<NonNullablePart<L, `${K & number}` | K, depth>, List>;
      • Make some entries of L not nullable (deeply or not)

        Parameter L

        to make non nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type NonNullableKeys

      type NonNullableKeys<L extends List> = ONonNullableKeys<ObjectOf<L>>;
      • Get the keys of L that are non-nullable

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Nullable

      type Nullable<L extends List, K extends Key = Key> = Cast<
      Update<L, `${K & number}` | K, x | null | undefined>,
      List
      >;
      • Make some entries of L nullable (deeply or not)

        Parameter L

        to make nullable

        Parameter K

        (?=Key) to choose fields

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type NullableKeys

      type NullableKeys<L extends List> = ONullableKeys<ObjectOf<L>>;
      • Get the keys of L that are nullable

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type ObjectOf

      type ObjectOf<O extends List> = O extends unknown
      ? number extends Length<O>
      ? _Pick<O, number>
      : _Omit<O, keyof any[]>
      : never;
      • Transform a [[List]] into an [[Object]] equivalent

        Parameter L

        to transform

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Omit

      type Omit<L extends List, K extends Key> = L extends unknown ? _Omit<L, K> : never;
      • Remove out of L the entries of key K

        Parameter L

        to remove from

        Parameter K

        to chose entries

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Optional

      type Optional<L extends List, depth extends Depth = 'flat'> = Cast<
      OptionalPart<L, depth>,
      List
      >;
      • Make L optional (deeply or not)

        Parameter L

        to make optional

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type OptionalKeys

      type OptionalKeys<L extends List> = OOptionalKeys<ObjectOf<L>>;
      • Get the keys of L that are optional

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Overwrite

      type Overwrite<L extends List, L1 extends object> = Cast<OOverwrite<L, L1>, List>;
      • Update the entries of L with the ones of L1

        Parameter L

        to update

        Parameter L1

        to update with

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type Partial

      type Partial<L extends List, depth extends Depth = 'flat'> = Cast<
      OPartial<L, depth>,
      List
      >;
      • Make all fields of O optional (deeply or not)

        Parameter L

        to make optional

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        import {O} from 'ts-toolbelt'
        type L = [1, 2, 3, [4, [5]]]
        type test0 = O.Partial<L>
        type test1 = O.Partial<L, 'deep'>

      type Patch

      type Patch<
      L extends List,
      L1 extends List,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = Cast<OPatch<L, L1, depth, ignore, fill>, List>;
      • Complete the fields of L with the ones of L1. This is a version of [[Merge]] that does NOT handle optional fields, it only completes fields of O with the ones of O1 if they don't exist.

        (⚠️ needs --strictNullChecks enabled)

        Parameter L

        to complete

        Parameter L1

        to copy from

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type PatchAll

      type PatchAll<
      O extends List,
      Ls extends List<List>,
      depth extends Depth = 'flat',
      ignore extends object = BuiltIn,
      fill extends any = never
      > = Cast<OPatchAll<O, Ls, depth, ignore, fill>, List>;
      • [[Patch]] a list of [[List]]s into L. Patches from left to right, first items get completed by the next ones (last-in completes).

        Parameter O

        to start with

        Parameter Os

        to patch

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Parameter ignore

        (?=BuiltIn) types not to merge

        Parameter fill

        (?=never) types of O to be replaced with ones of O1

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Path

      type Path<L extends List, Path extends List<Key>> = OPath<L, Path>;
      • Get in L the type of nested properties

        Parameter L

        to be inspected

        Parameter Path

        to be followed

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type Paths

      type Paths<L extends List> = OPaths<ObjectOf<L>>;
      • Get all the possible paths of L (⚠️ this won't work with circular-refs)

        Parameter L

        to be inspected

        Returns

        [[String]][]

        Example 1

        ```ts ```

      type Pick

      type Pick<L extends List, K extends Key> = L extends unknown ? _Pick<L, K> : never;
      • Extract out of L the entries of key K

        Parameter L

        to extract from

        Parameter K

        to chose entries

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Pop

      type Pop<L extends List> = L extends
      | readonly [...infer LBody, any]
      | readonly [...infer LBody, any?]
      ? LBody
      : L;
      • Remove the last element out of L

        Parameter L

        to remove from

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Prepend

      type Prepend<L extends List, A extends any> = [A, ...L];
      • Add an element A at the beginning of L

        Parameter L

        to append to

        Parameter A

        to be added to

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Readonly

      type Readonly<L extends List, depth extends Depth = 'flat'> = Cast<
      ReadonlyPart<L, depth>,
      List
      >;
      • Make L readonly (deeply or not)

        Parameter L

        to make readonly

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type ReadonlyKeys

      type ReadonlyKeys<L extends List> = OReadonlyKeys<ObjectOf<L>>;
      • Get the keys of L that are readonly

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Remove

      type Remove<L extends List, From extends number, To extends number> = Omit<
      L,
      KeySet<From, To>
      >;
      • Remove out of L a range of entries

        Parameter L

        to remove from

        Parameter From

        to start from

        Parameter To

        to end with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Repeat

      type Repeat<A extends any, N extends number, L extends List = []> = N extends unknown
      ? L extends unknown
      ? _Repeat<A, N, L>
      : never
      : never;
      • Fill a [[List]] with N times A

        Parameter A

        to fill with

        Parameter N

        to repeat it

        Parameter L

        (?=[]) to be filled

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Replace

      type Replace<
      L extends List,
      M extends any,
      A extends any,
      match extends Match = 'default'
      > = Cast<OReplace<L, M, A, match>, List>;
      • Update with A the entries of L that match M

        Parameter O

        to update

        Parameter M

        to select fields

        Parameter A

        to update with

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Required

      type Required<L extends List, depth extends Depth = 'flat'> = Cast<
      RequiredPart<L, depth>,
      List
      >;
      • Make L required (deeply or not)

        Parameter L

        to make required

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type RequiredKeys

      type RequiredKeys<L extends List> = ORequiredKeys<ObjectOf<L>>;
      • Get the keys of L that are readonly

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Reverse

      type Reverse<L extends List> = L extends unknown ? _Reverse<L> : never;
      • Turn a [[List]] the other way around

        Parameter L

        to reverse

        Parameter LO

        (?=[]) to prepend to

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Select

      type Select<L extends List, M extends any, match extends Match = 'default'> = ListOf<
      OSelect<ObjectOf<L>, M, match>
      >;
      • Extract the entries of L that match M

        Parameter L

        to extract from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[List]]

        Example 1

        ```ts ```

      type SelectKeys

      type SelectKeys<
      L extends List,
      M extends any,
      match extends Match = 'default'
      > = OSelectKeys<ObjectOf<L>, M, match>;
      • Get the keys of L which entries match M

        Parameter L

        to extract from

        Parameter M

        to select entries

        Parameter match

        (?='default') to change precision

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Shortest

      type Shortest<L extends List, L1 extends List> = L extends unknown
      ? L1 extends unknown
      ? {
      0: L1;
      1: L;
      }[Has<keyof L1, keyof L>]
      : never
      : never;
      • Get the shortest [[List]] of L & L1 (L has priority if both lengths are equal)

        Parameter L

        to compare length

        Parameter L1

        to compare length

        Returns

        L | L1

        Example 1

        ```ts ```

      type Tail

      type Tail<L extends List> = L extends readonly []
      ? L
      : L extends readonly [any?, ...infer LTail]
      ? LTail
      : L;
      • Remove the first item out of a [[List]]

        Parameter L

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Take

      type Take<
      L extends List,
      N extends number,
      way extends Way = '->'
      > = L extends unknown ? (N extends unknown ? _Take<L, N, way> : never) : never;
      • Extract N entries out of L

        Parameter L

        to extract from

        Parameter N

        to extract out

        Parameter way

        (?='->') to extract from end

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Undefinable

      type Undefinable<L extends List, K extends Key = Key> = Cast<
      Update<L, `${K & number}` | K, x | undefined>,
      List
      >;
      • Make some entries of L not undefined (deeply or not)

        Parameter L

        to make non nullable

        Parameter K

        (?=Key) to choose fields

        Returns

        [[List]]

        Example 1

        ```ts ```

      type UndefinableKeys

      type UndefinableKeys<L extends List> = OUndefinableKeys<ObjectOf<L>>;
      • Get the keys of L that are undefined

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Unionize

      type Unionize<L extends List, L1 extends List, K extends Key = Key> = {
      [P in keyof L]: P extends K ? L[P] | At<L1, P> : L[P];
      };
      • Make the fields of L union the ones of L1

        Parameter L

        to union from

        Parameter L1

        to union with

        Parameter K

        (?=Key) to do choose fields

        Returns

        [[List]]

        Example 1

        ```ts ```

      type UnionOf

      type UnionOf<L extends List> = L[number];
      • Transform a [[List]] into an [[Union]]

        Parameter L

        to transform

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type UnNest

      type UnNest<L extends List, strict extends Boolean = 1> = L extends unknown
      ? _UnNest<L, strict>
      : never;
      • Remove a dimension of L

        Parameter L

        to un-nest

        Parameter strict

        (?=1) 0 to not preserve tuples

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Update

      type Update<L extends List, K extends Key, A extends any> = Cast<
      OUpdate<L, `${K & number}` | K, A>,
      List
      >;
      • Update in L the entries of key K with A. Use the [[x]] placeholder to get the current field type.

        Parameter L

        to update

        Parameter K

        to chose fields

        Parameter A

        to update with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Writable

      type Writable<L extends List, depth extends Depth = 'flat'> = Cast<
      WritablePart<L, depth>,
      List
      >;
      • Make L writable (deeply or not)

        Parameter L

        to make writable

        Parameter depth

        (?='flat') 'deep' to do it deeply

        Returns

        [[List]]

        Example 1

        ```ts ```

      type WritableKeys

      type WritableKeys<L extends List> = OWritableKeys<ObjectOf<L>>;
      • Get the keys of L that are writable

        Parameter L

        Returns

        [[Key]]

        Example 1

        ```ts ```

      type Zip

      type Zip<L extends List, L1 extends List> = L extends unknown
      ? L1 extends unknown
      ? _Zip<L, L1>
      : never
      : never;
      • Pair up the entries of L with L1

        Parameter L

        to pair up

        Parameter L1

        to pair up with

        Returns

        [[List]]

        Example 1

        ```ts ```

      type ZipObj

      type ZipObj<LKeys extends List<Key>, LFields extends List> = LKeys extends unknown
      ? LFields extends unknown
      ? _ZipObj<LKeys, LFields>
      : never
      : never;
      • Create an [[Object]] from [[List]]s of keys & fields

        Parameter LKeys

        its keys

        Parameter LFields

        its fields

        Returns

        [[Object]]

        Example 1

        ```ts ```

      namespace U

      module 'out/Union/_api.d.ts' {}

      type Diff

      type Diff<U1 extends any, U2 extends any> = Exclude<U1, U2> | Exclude<U2, U1>;
      • Get an [[Union]] that is the difference between U1 & U2

        Parameter U1

        to check differences with

        Parameter U2

        to check differences against

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Exclude

      type Exclude<U extends any, M extends any> = U extends M ? never : U;
      • Remove M out of U

        Parameter U

        to remove from

        Parameter M

        to remove out

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Filter

      type Filter<
      U extends any,
      M extends any,
      match extends Match = 'default'
      > = U extends unknown
      ? {
      1: never;
      0: U & M;
      }[Is<U, M, match>]
      : never;
      • Remove M out of U

        Parameter U

        to remove from

        Parameter M

        to remove out

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Has

      type Has<U extends any, U1 extends any> = [U1] extends [U] ? 1 : 0;
      • Check whether U contains U1

        Parameter U

        to be inspected

        Parameter U1

        to check within

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Intersect

      type Intersect<U1 extends any, U2 extends any> = U1 extends unknown
      ? U2 extends unknown
      ? {
      1: U1;
      0: never;
      }[Equals<U1, U2>]
      : never
      : never;
      • Get the overlapping members of U1 and U2

        Parameter U1

        Parameter U2

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type IntersectOf

      type IntersectOf<U extends any> = (
      U extends unknown ? (k: U) => void : never
      ) extends (k: infer I) => void
      ? I
      : never;
      • Transform a [[Union]] to an * *intersection**

        Parameter U

        to transform

        Returns

        &

        Example 1

        ```ts ```

      type Last

      type Last<U extends any> = IntersectOf<
      U extends unknown ? (x: U) => void : never
      > extends (x: infer P) => void
      ? P
      : never;
      • Get the last item within an [[Union]] (⚠️ it might not preserve order)

        Parameter U

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type ListOf

      type ListOf<U extends any> = _ListOf<U> extends infer X ? Cast<X, List> : never;
      • Transform a [[Union]] into a [[List]] (⚠️ it might not preserve order)

        Parameter U

        to transform

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Merge

      type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
      • Merge a [[Union]] of [[Object]]s into a single one

        Parameter U

        to merge

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NonNullable

      type NonNullable<U extends any> = Exclude<U, undefined | null>;
      • Remove undefined & null out of U

        Parameter U

        to make non-nullable

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Nullable

      type Nullable<U extends any> = U | undefined | null;
      • Add undefined | null to U

        Parameter U

        to make nullable

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Pop

      type Pop<U extends any> = Exclude<U, Last<U>>;
      • Remove an item out of U (⚠️ it might not preserve order)

        Parameter U

        to remove from

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Replace

      type Replace<
      U extends any,
      M extends any,
      A extends any,
      match extends Match = 'default'
      > = U extends unknown
      ? {
      1: A;
      0: U;
      }[Is<U, M, match>]
      : never;
      • Replace M with A in U

        Parameter U

        to update

        Parameter M

        to select

        Parameter A

        to update with

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Select

      type Select<
      U extends any,
      M extends any,
      match extends Match = 'default'
      > = U extends unknown
      ? {
      1: U & M;
      0: never;
      }[Is<U, M, match>]
      : never;
      • Extract the part of U that matches M

        Parameter U

        to extract from

        Parameter M

        to select with

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Strict

      type Strict<U extends object> = ComputeRaw<_Strict<U>>;
      • Make a [[Union]] not allow excess properties (https://github.com/Microsoft/TypeScript/issues/20863)

        Parameter U

        to make strict

        Returns

        [[Union]]

        Example 1

        ```ts ```

      namespace Union

      module 'out/Union/_api.d.ts' {}

      type Diff

      type Diff<U1 extends any, U2 extends any> = Exclude<U1, U2> | Exclude<U2, U1>;
      • Get an [[Union]] that is the difference between U1 & U2

        Parameter U1

        to check differences with

        Parameter U2

        to check differences against

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Exclude

      type Exclude<U extends any, M extends any> = U extends M ? never : U;
      • Remove M out of U

        Parameter U

        to remove from

        Parameter M

        to remove out

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Filter

      type Filter<
      U extends any,
      M extends any,
      match extends Match = 'default'
      > = U extends unknown
      ? {
      1: never;
      0: U & M;
      }[Is<U, M, match>]
      : never;
      • Remove M out of U

        Parameter U

        to remove from

        Parameter M

        to remove out

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Has

      type Has<U extends any, U1 extends any> = [U1] extends [U] ? 1 : 0;
      • Check whether U contains U1

        Parameter U

        to be inspected

        Parameter U1

        to check within

        Returns

        [[Boolean]]

        Example 1

        ```ts ```

      type Intersect

      type Intersect<U1 extends any, U2 extends any> = U1 extends unknown
      ? U2 extends unknown
      ? {
      1: U1;
      0: never;
      }[Equals<U1, U2>]
      : never
      : never;
      • Get the overlapping members of U1 and U2

        Parameter U1

        Parameter U2

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type IntersectOf

      type IntersectOf<U extends any> = (
      U extends unknown ? (k: U) => void : never
      ) extends (k: infer I) => void
      ? I
      : never;
      • Transform a [[Union]] to an * *intersection**

        Parameter U

        to transform

        Returns

        &

        Example 1

        ```ts ```

      type Last

      type Last<U extends any> = IntersectOf<
      U extends unknown ? (x: U) => void : never
      > extends (x: infer P) => void
      ? P
      : never;
      • Get the last item within an [[Union]] (⚠️ it might not preserve order)

        Parameter U

        Returns

        [[Any]]

        Example 1

        ```ts ```

      type ListOf

      type ListOf<U extends any> = _ListOf<U> extends infer X ? Cast<X, List> : never;
      • Transform a [[Union]] into a [[List]] (⚠️ it might not preserve order)

        Parameter U

        to transform

        Returns

        [[List]]

        Example 1

        ```ts ```

      type Merge

      type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
      • Merge a [[Union]] of [[Object]]s into a single one

        Parameter U

        to merge

        Returns

        [[Object]]

        Example 1

        ```ts ```

      type NonNullable

      type NonNullable<U extends any> = Exclude<U, undefined | null>;
      • Remove undefined & null out of U

        Parameter U

        to make non-nullable

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Nullable

      type Nullable<U extends any> = U | undefined | null;
      • Add undefined | null to U

        Parameter U

        to make nullable

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Pop

      type Pop<U extends any> = Exclude<U, Last<U>>;
      • Remove an item out of U (⚠️ it might not preserve order)

        Parameter U

        to remove from

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Replace

      type Replace<
      U extends any,
      M extends any,
      A extends any,
      match extends Match = 'default'
      > = U extends unknown
      ? {
      1: A;
      0: U;
      }[Is<U, M, match>]
      : never;
      • Replace M with A in U

        Parameter U

        to update

        Parameter M

        to select

        Parameter A

        to update with

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Select

      type Select<
      U extends any,
      M extends any,
      match extends Match = 'default'
      > = U extends unknown
      ? {
      1: U & M;
      0: never;
      }[Is<U, M, match>]
      : never;
      • Extract the part of U that matches M

        Parameter U

        to extract from

        Parameter M

        to select with

        Returns

        [[Union]]

        Example 1

        ```ts ```

      type Strict

      type Strict<U extends object> = ComputeRaw<_Strict<U>>;
      • Make a [[Union]] not allow excess properties (https://github.com/Microsoft/TypeScript/issues/20863)

        Parameter U

        to make strict

        Returns

        [[Union]]

        Example 1

        ```ts ```

      Package Files (225)

      Dependencies (0)

      No dependencies.

      Dev Dependencies (15)

      Peer Dependencies (0)

      No peer dependencies.

      Badge

      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ts-toolbelt.

      • Markdown
        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ts-toolbelt)
      • HTML
        <a href="https://www.jsdocs.io/package/ts-toolbelt"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>