Skip to content

Types Reference

License NPM Version Open Issues Size

🏷️ Collection of TypeScript types shared across Lou Codes projects.

Usage

πŸ“¦ Node

Install @lou.codes/types as a dependency:

Terminal window
1
pnpm add @lou.codes/types
2
# or
3
npm install @lou.codes/types
4
# or
5
yarn add @lou.codes/types

Import as type and use it:

1
import type { Unary } from "@lou.codes/types";

πŸ¦• Deno

Import @lou.codes/types using the npm: prefix, and use it directly:

1
import type { Unary } from "npm:@lou.codes/types";
  • πŸ“ Documentation: TypeDoc generated documentation.
  • ⏳ Changelog: List of changes between versions.

Array

ArrayLike

Ζ¬ ArrayLike<Item, Length>: ReadOnlyRecord<NeverFallback<Exclude<Enumerate<Length>, Length>, number>, Item> & { length: Length }

An alternative for TypeScript’s ArrayLike type, with its type set to unknown by default. It also makes it shallowly read-only.

Remarks

When working with optional types, having to type ArrayLike<unknown> every time gets annoying pretty fast. This type is a drop-in replacement for ArrayLike, with the only difference being that the type of the items is set to unknown by default.

Example

1
const arrayLike: ArrayLike<number> = [1, 2, 3];

Type parameters

NameTypeDescription
ItemunknownType of the items in the array-like object.
Lengthextends number = number-

View source


Empty

Empty array, object or string.

Remarks

Union type of EmptyArray, EmptyRecord and EmptyString, to signify values that are empty.

Example

1
const emptyString: Empty = "";
2
const emptyArray: Empty = [];
3
const emptyRecord: Empty = {};

See

View source


EmptyArray

Ζ¬ EmptyArray: typeof EMPTY_ARRAY

Empty array.

Remarks

This is a type alias for an readonly empty array. Trying to access items on it will give a compile-time error.

Example

1
const emptyArray: EmptyArray = [];

View source


Entry

Ζ¬ Entry<Key, Value>: readonly [key: Key, value: Value]

Entry couple [key, value].

Remarks

It is a tuple of two elements, the first one being the key and the second one being the value of an object’s property.

Example

1
const entry: Entry<string, number> = ["🟒", 1];

Type parameters

NameTypeDescription
KeyPropertyKeyObject’s properties type.
ValueunknownObject’s values type.

View source


EntryKey

Ζ¬ EntryKey<Input>: Input[0]

Key of an Entry.

Remarks

Util type to get the key of an Entry.

Example

1
const entry: Entry<string, number> = ["🟒", 1];
2
const entryKey: EntryKey<typeof entry> = entry[0];

See

Entry

Type parameters

NameTypeDescription
Inputextends EntryEntry type.

View source


EntryOf

Ζ¬ EntryOf<Type>: Entry<KeyOf<Type>, ValueOf<Type>>

Object or array Entry.

Remarks

Get the Entry type out of an object or array.

Example

1
const object = {
2
"🟒": 1,
3
"🟩": 2,
4
};
5
const entries: EntryOf<typeof object> = Object.entries(object)[0];

See

Type parameters

NameTypeDescription
Typeextends objectObject or array type.

View source


EntryValue

Ζ¬ EntryValue<Input>: Input[1]

Value of an Entry.

Remarks

Util type to get the value of an Entry.

Example

1
const entry: Entry<string, number> = ["🟒", 1];
2
const entryValue: EntryValue<typeof entry> = entry[1];

See

Entry

Type parameters

NameTypeDescription
Inputextends EntryEntry type.

View source


Ζ¬ Head<Input>: HeadAndTail<Input>[0]

Initial value of an ArrayLike.

Remarks

Given a type argument (an ArrayLike), this returns the type of the item in index 0.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const head: Head<typeof array> = "🟒";

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeArrayLike value (such as Array or string).

View source


HeadAndTail

Ζ¬ HeadAndTail<Input>: Input extends readonly [head: infer HeadItem, tail: infer TailItems] ? readonly [head: HeadItem, tail: TailItems] : Input extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [head: FirstCharacter, tail: RestOfString] : Input extends EmptyArray | EmptyString ? readonly [head: undefined, tail: Input] : readonly [head: Maybe<Input[number]>, tail: Input]

Get a couple with the head and tail types of an ArrayLike.

Remarks

Given a type argument (an ArrayLike), this returns a couple with the type of the item in index 0 first, and the rest of the ArrayLike after.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const headAndTail: HeadAndTail<typeof array> = ["🟒", ["🟩", "πŸ’š"]];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeInput ArrayLike.

View source


Initial

Ζ¬ Initial<Input>: InitialAndLast<Input>[0]

Initial values of an ArrayLike (omitting the last).

Remarks

Given a type argument (an ArrayLike), this returns the type of the items from the start of the ArrayLike until the before to last item.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const initial: Initial<typeof array> = ["🟒", "🟩"];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeArrayLike value (such as Array or string).

View source


InitialAndLast

Ζ¬ InitialAndLast<Input>: Input extends readonly […(infer InitialItems), infer LastItem] ? readonly [initial: InitialItems, last: LastItem] : Input extends EmptyArray | EmptyString ? readonly [initial: Input, last: undefined] : Input extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [initial: `${RestOfString extends EmptyString ? EmptyString : FirstCharacter}${Head<InitialAndLast<RestOfString>>}`, last: `${RestOfString extends EmptyString ? FirstCharacter : Last<RestOfString>}`] : readonly [initial: Input, last: Maybe<Input[number]>]

Get a couple with the initial and last types of an ArrayLike.

Remarks

Given a ArrayLike, this returns a couple with the type of all items from the start until the item before last, and then the last.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const initialAndLast: InitialAndLast<typeof array> = [["🟒", "🟩"], "πŸ’š"];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeInput ArrayLike.

View source


KeyOf

Ζ¬ KeyOf<Type>: Type extends ArrayLike ? NeverFallback<Just<Exclude<Partial<Type>["length"], Type["length"]>>, number> : `${Exclude<keyof Type, symbol>}`

Generic key for either object or array.

Remarks

Type to represent the type of the key in an array or object. It automatically omits symbol keys from objects, and uses number for arrays with dynamic length.

Example

1
const array = [1, 2, 3] as const;
2
const object = { "🟒": "🟩" } as const;
3
4
const arrayKey: KeyOf<typeof array> = 0;
5
const objectKey: KeyOf<typeof object> = "🟒";

Type parameters

NameTypeDescription
Typeextends objectObject or array type.

View source


Last

Ζ¬ Last<Input>: InitialAndLast<Input>[1]

Last value of an ArrayLike.

Remarks

Type of the last character of a string or the last element of an array.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const last: Last<typeof array> = "πŸ’š";

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeThe input ArrayLike.

View source


MaybeEmpty

Ζ¬ MaybeEmpty<Input>: Either<Input, Input extends ReadOnlyArray ? EmptyArray : Input extends string ? EmptyString : Input extends ReadOnlyRecord ? EmptyRecord : undefined>

Creates an union of the given type with a possible β€œempty” value.

Remarks

This type is useful to make clear that we expect a possible empty value.

Example

1
type Greet: MaybeEmpty<"Hello">; // "Hello" | ""
2
type Triple: MaybeEmpty<readonly [1, 2, 3]>; // readonly [1, 2, 3] | readonly []
3
type Foo: MaybeEmpty<{ readonly foo: "bar" }>; // { readonly foo: "bar" } | {}

See

Type parameters

NameDescription
InputType to unite with it’s empty counterpart.

View source


NotEmpty

Ζ¬ NotEmpty<Type>: Exclude<Type, Empty>

Type for a non-empty ArrayLike, object or string.

Remarks

This type is useful for cases where you want to ensure that a value is not empty. For example, if you have an array that should always have at least one element, you could type it as NotEmpty<ArrayLike<ElementType>>.

Example

1
const notEmptyString: NotEmpty<string> = "🟒";
2
const notEmptyArray: NotEmpty<ReadOnlyArray> = ["🟒", "🟩"];
3
const notEmptyRecord: NotEmpty<ReadOnlyRecord> = { "🟒": "🟩" };

See

Empty

Type parameters

NameTypeDescription
Typeextends ArrayLike | object | stringThe type to check.

View source


ReadOnlyArray

Ζ¬ ReadOnlyArray<Item>: ReadonlyArray<Item>

An alternative for TypeScript’s ReadonlyArray type, with its type set to unknown by default.

Remarks

There’s already a native ReadonlyArray type, but this type has a default type parameter to make it easier to use when the type of an array is unknown.

Example

1
const array: ReadOnlyArray<{ "🟒": number }> = [{ "🟒": 1 }, { "🟒": 2 }];
2
array[0]["🟒"] = 3; // Error

Type parameters

NameTypeDescription
ItemunknownType of the items in the array.

View source


Reducer

Ζ¬ Reducer<Item, Accumulator>: Unary<Item, Unary<Accumulator, Accumulator>>

Reducer/Folder function.

Remarks

Type to represent a folder/reducer unary function that takes an item and an accumulator something of the type of the accumulator.

Example

1
const reducer: Reducer<number, number> = item => accumulator =>
2
accumulator + item;

See

Unary

Type parameters

NameDescription
ItemType of the items to reduce.
AccumulatorType of the accumulator/output.

View source


Tail

Ζ¬ Tail<Input>: HeadAndTail<Input>[1]

Last values of an ArrayLike (omitting the first).

Remarks

Type of the last items of an ArrayLike, excluding the first item in said ArrayLike.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const tail: Tail<typeof array> = ["🟩", "πŸ’š"];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeType of the array to get the tail.

View source


ValueOf

Ζ¬ ValueOf<Type>: KeyOf<Type> extends keyof Type ? Type[KeyOf<Type>] : never

Generic key for either object or array.

Remarks

This type is used to get the type of the values in a collection (items of an ArrayLike or properties of a Record).

Example

1
const object = {
2
"🟒": 1,
3
"🟩": 2,
4
};
5
const key: ValueOf<typeof object> = 1;

See

KeyOf

Type parameters

NameTypeDescription
Typeextends objectObject or array type.

View source

Common

Awaitable

Ζ¬ Awaitable<Type>: PromiseLike<Type> | Type

A value that might be coming from a Promise.

Remarks

Union type useful when you want to accept both Promise and non-Promise for a given type, both β€œawaitable”.

Example

1
type AwaitableString = Awaitable<string>;
2
const promisedValue: AwaitableString = Promise.resolve("🟒");
3
const plainValue: AwaitableString = "🟩";
4
5
Promise.all([promisedValue, plainValue]).then(console.log); // ["🟒", "🟩"]

See

Promise

Type parameters

NameTypeDescription
TypeunknownThe type to await.

View source


Either

Ζ¬ Either<Right, Left>: Right | Left

Value that can be something or something else.

Remarks

Union type useful for cases where a value might be of one type or another. By convention we use Right for the β€œsuccess” type and Left for the error.

Example

1
type MaybeNumber = Either<number, string>;
2
const maybeNumber: MaybeNumber = 1;
3
const notNumber: MaybeNumber = "1";

Type parameters

NameDescription
RightThe β€œcorrect” type.
LeftThe β€œerror” type.

View source


Falsy

Ζ¬ Falsy: EmptyString | HTMLAllCollection | Nullish | 0 | 0n | false

Types that evaluates to false in JS.

Remarks

Union type of the values that evaluate to false in JavaScript. Due to TypeScript type limitations NaN can’t be included.

Example

1
const falsyBoolean: Falsy = false;
2
const falsyHTMLAllCollection: Falsy = document.all;
3
const falsyNegativeZero: Falsy = -0;
4
const falsyNegativeZeroBigInt: Falsy = -0n;
5
const falsyNull: Falsy = null;
6
const falsyString: Falsy = "";
7
const falsyUndefined: Falsy = undefined;
8
const falsyZero: Falsy = 0;
9
const falsyZeroBigInt: Falsy = 0n;

See

View source


JSONValue

Ζ¬ JSONValue: Exclude<Primitive, bigint | symbol | undefined> | ReadonlyArray<JSONValue> | { [property: string]: JSONValue; }

Possible parsed JSON value.

Remarks

Following the JSON specification, the result of a JSON.parse call can be one of a given set of types. This type is a union of all of those types.

Example

1
const json: JSONValue = JSON.parse('{"foo": "bar"}');

See

JSON

View source


Just

Ζ¬ Just<Input>: Exclude<Input, undefined>

Excludes undefined of a type union.

Remarks

Every now and then a type is possibly undefined, this type gets rid of the undefined in the union.

Example

1
const maybeUndefined: string | undefined = "🟒";
2
const defined: Just<typeof maybeUndefined> = "🟒"; // ok
3
const noDefined: Just<typeof maybeUndefined> = undefined; // error

See

Maybe

Type parameters

Name
Input

View source


Maybe

Ζ¬ Maybe<Input>: Either<Just<Input>, undefined>

Value that can be undefined.

Remarks

Union type useful for cases where a value might be undefined, and provides a simple way to express this in TypeScript. For example, the return type of a function that returns a string or undefined could be typed as Maybe<string>.

Example

1
type MaybeNumber = Maybe<number>;
2
const maybeNumber: MaybeNumber = 1;
3
const notNumber: MaybeNumber = undefined;

See

Just

Type parameters

NameDescription
InputThe type of the value to make optional.

View source


NeverFallback

Ζ¬ NeverFallback<MaybeNever, Fallback>: Single<MaybeNever> extends Single<never> ? Fallback : MaybeNever

Takes a value that could be never, and if it is never it goes to the Fallback value.

Remarks

There are some scenarios where a value can end up being of type never, this works sorta like the the ?? operator, but for never.

Example

1
const value: never = undefined as never;
2
NeverFallback<typeof value, number>; // Will be number

See

Single

Type parameters

NameDescription
MaybeNeverThe type that may or may not be never.
FallbackThe fallback type to use if MaybeNever is never.

View source


Nullish

Ζ¬ Nullish: Maybe<null>

Nullish value (either null or undefined).

Remarks

This type is useful for cases where a value might be null or undefined, generally meant to be dealt with using the ?? operator.

Example

1
const nullishUndefined: Nullish = undefined;
2
const nullishNull: Nullish = null;

See

View source


Primitive

Ζ¬ Primitive: Nullish | Numeric | boolean | string | symbol

Valid JavaScript primitives.

Remarks

This type is a union of all the valid JavaScript primitives, including null, undefined, boolean, number, bigint, string, and symbol.

Example

1
const aBigInt: Primitive = 13n;
2
const aBoolean: Primitive = true;
3
const aNull: Primitive = null;
4
const aNumber: Primitive = 13;
5
const anUndefined: Primitive = undefined;
6
const aString: Primitive = "🟒";
7
const aSymbol: Primitive = Symbol("🟒");

See

View source


Replace

Ζ¬ Replace<Type, Keys, NewType>: Omit<Type, Keys> & { readonly [Property in Keys]: NewType }

Intersection that replaces the type of some keys in given object type.

Remarks

Intersection type to replace all the given keys of an object type with a new type.

Example

1
type User = { name: string; age: number };
2
type ReallyOldUser = Replace<User, "age", bigint>;

Type parameters

NameTypeDescription
Typeextends objectType to replace the type of some keys in.
Keysextends keyof TypeKeys to replace the type of.
NewTypeNewTypeNew type to replace the old type with.

View source


Single

Ζ¬ Single<Type>: readonly [single: Type]

Tuple of length 1 (AKA Monuple).

Remarks

Tuple with a single element on it, useful when doing optional types that compare to never.

Example

1
const single: Single<boolean> = [true];

Type parameters

NameDescription
TypeType of the single element.

View source


Strigifiable

Ζ¬ Strigifiable: Exclude<Primitive, symbol>

Values that can be stringified.

Remarks

Type to represent all values that can be stringified, all primitives excluding symbol: string, number, bigint, boolean, undefined, and null.

Example

1
let value: Strigifiable = "hello";
2
value = 1;
3
value = true;
4
value = Symbol("hello"); // Error!
5
value = { toString: () => "hello" }; // Error!

See

Primitive

View source


Truthy

Ζ¬ Truthy<Type>: Exclude<Type, Falsy>

Excludes all Falsy values of the given Type.

Remarks

Type to represent all values of the given Type that are not Falsy. If all types are Falsy, the result is never.

Example

1
Truthy<"" | "truthy">; // "truthy"

See

Falsy

Type parameters

NameTypeDescription
TypeunknownType to exclude Falsy values from.

View source


TypeOfDictionary

Ζ¬ TypeOfDictionary: Object

typeof dictionary.

Remarks

Dictionary of types and their typeof values, including the proposed but never added type "null" for null.

Example

1
TypeOfMap["string"]; // `string`
2
TypeOfMap["boolean"]; // `boolean`
3
TypeOfMap["function"]; // `GenericFunction`

See

Type declaration

NameTypeDescription
bigintbigintTypeOfDictionary key for BigInt
booleanbooleanTypeOfDictionary key for Boolean
functionFunctionTypeOfDictionary key for Function
nullnullTypeOfDictionary key for null
numbernumberTypeOfDictionary key for Number
objectobjectTypeOfDictionary key for Object
stringstringTypeOfDictionary key for String
symbolsymbolTypeOfDictionary key for Symbol
undefinedundefinedTypeOfDictionary key for undefined

View source


TypeOfValue

Ζ¬ TypeOfValue: KeyOf<TypeOfDictionary>

Possible type values returned by typeof.

Remarks

Type to represent the possible values returned by typeof, including the proposed but never added type "null" for null.

Example

1
const typeString: TyeOfValue = "string";
2
const typeBoolean: TyeOfValue = "boolean";
3
const typeFunction: TyeOfValue = "function";

See

View source


Unbound

Ζ¬ Unbound<Type>: Type extends ReadonlyArray<infer Item> ? { [Property in keyof ReadonlyArray<Item>]: ReadonlyArray<Item>[Property] extends Function ? Function : ReadonlyArray<Item>[Property] } : { [Property in keyof Type]: Type[Property] extends Function ? Function : Type[Property] }

Type that replaces adds the this: void argument to all the methods in the given Type.

Remarks

This type is used when the unbound of all methods is automated.

Example

1
Unbound < Date > ["getTime"]; // (this: void) => number

Type parameters

NameTypeDescription
TypeunknownType to be unbounded.

View source

Date

DayOfMonth

Ζ¬ DayOfMonth: Range<1, 31>

Day of the month values in numeric format (from 1 to 31).

Remarks

Stricter than number type for day of the month values, limited to valid values from 1 to 31, and giving type errors otherwise.

Example

1
const days: Iterable<DayOfMonth> = [1, 2, 3, 28, 29, 30, 31];

See

View source


DayOfWeek

Ζ¬ DayOfWeek: Enumerate<6>

Day of the week values in numeric format (from 0 to 6).

Remarks

Stricter than number type for day of the week values, limited to valid values from 0 to 6, and giving type errors otherwise.

Example

1
const daysOfWeek: Iterable<DayOfWeek> = [0, 1, 2, 3, 4, 5, 6];

See

View source


Hours

Ζ¬ Hours: Enumerate<23>

Hours values in numeric format (from 0 to 23).

Remarks

Stricter than number type for hour values, limited to valid values from 0 to 23, and giving type errors otherwise.

Example

1
const hours: Iterable<Hours> = [0, 1, 2, 3, 20, 21, 22, 23];

See

View source


ISODate

Ζ¬ ISODate: `${ISOYear}-${ISOMonth}-${ISODayOfMonth}T${MultiDigitNumberString}:${MultiDigitNumberString}:${MultiDigitNumberString}.${MultiDigitNumberString}Z`

String representing an ISO date.

Remarks

This type is a string representing an ISO 8601 format of a date (returned by Date#toISOString). It uses MultiDigitNumberString because the type complexity using better types is too hight.

Example

1
const date: ISODate = "2020-01-01T00:00:00.000Z";

See

View source


ISODayOfMonth

Ζ¬ ISODayOfMonth: `0${Exclude<Digit, 0>}` | `${1 | 2}${Digit}` | `3${Enumerate<1>}`

Day of the month values in string format ("01" to "31").

Remarks

Union type stricter than string type for day of the month values, limited to valid values from "01" to "31", and giving type errors otherwise.

Example

1
const days: Iterable<ISODayOfMonth> = ["01", "15", "31"];

See

View source


ISOHours

Ζ¬ ISOHours: `${Enumerate<1>}${Digit}` | `2${Enumerate<3>}`

Hours values in string format (from "00" to "23").

Remarks

Union type stricter than string type for hour values, limited to valid values from "00" to "23", and giving type errors otherwise.

Example

1
const hours: Iterable<ISOHours> = ["00", "06", "23"];

See

View source


ISOMilliseconds

Ζ¬ ISOMilliseconds: `${Digit}${Digit}${Digit}`

ISO milliseconds values in string format (from "000" to "999").

Remarks

Stricter than string type for millisecond values, limited to valid values from "000" to "999", and giving type errors otherwise.

Example

1
const milliseconds: Iterable<ISOMilliseconds> = ["001", "250", "999"];

See

View source


ISOMinutes

Ζ¬ ISOMinutes: `${Enumerate<5>}${Digit}`

ISO minutes values in string format (from "00" to "59").

Remarks

Stricter than string type for minute values, limited to valid values from "00" to "59", and giving type errors otherwise.

Example

1
const minutes: Iterable<ISOMinutes> = ["00", "30", "59"];

See

View source


ISOMonth

Ζ¬ ISOMonth: `0${Exclude<Digit, 0>}` | `1${Enumerate<2>}`

ISO Month values in string format (from "01" to "12").

Remarks

Union type stricter than string type for month values, limited to valid values from "01" to "12", and giving type errors otherwise.

Example

1
const months: Iterable<ISOMonth> = ["01", "06", "12"];

See

View source


ISOSeconds

Ζ¬ ISOSeconds: `${Enumerate<5>}${Digit}`

ISO seconds values in string format (from "00" to "59").

Remarks

Stricter than string type for seconds values, limited to valid values from "00" to "59", and giving type errors otherwise.

Example

1
const seconds: Iterable<ISOSeconds> = ["00", "30", "59"];

See

View source


ISOYear

Ζ¬ ISOYear: `${EmptyString | β€œ-00”}${MultiDigitNumberString}`

ISO year values in string format.

Remarks

Stricter than string type for year values, limited to valid values from "-271821" to "275760", and giving type errors otherwise.

Example

1
const years: Iterable<ISOYear> = ["2020", "-001000", "1989"];

See

Date

View source


Milliseconds

Ζ¬ Milliseconds: Enumerate<999>

ISO milliseconds values in number format (from 0 to 999).

Remarks

Stricter than number type for millisecond values, limited to valid values from 0 to 999, and giving type errors otherwise.

Example

1
const milliseconds: Iterable<Milliseconds> = [1, 250, 999];

See

View source


Minutes

Ζ¬ Minutes: Enumerate<59>

ISO minutes values in number format (from 0 to 59).

Remarks

Stricter than number type for minute values, limited to valid values from 0 to 59, and giving type errors otherwise.

Example

1
const minutes: Iterable<Minutes> = [0, 30, 59];

See

View source


Month

Ζ¬ Month: Enumerate<11>

ISO Month values in number format (from 0 to 11).

Remarks

Stricter than number type for month values, limited to valid values from 0 to 11, and giving type errors otherwise.

Example

1
const months: Iterable<ISOMonth> = [1, 6, 11];

See

View source


Seconds

Ζ¬ Seconds: Enumerate<59>

ISO seconds values in number format (from 0 to 59).

Remarks

Stricter than number type for seconds values, limited to valid values from 0 to 59, and giving type errors otherwise.

Example

1
const seconds: Iterable<Seconds> = [0, 30, 59];

See

View source

Function

Class

Ζ¬ Class<Arguments, Instance>: (…constructorArguments: Arguments) => Instance

A generic type for classes.

Remarks

This type is a generic constructor function, mainly used when wrapping classes.

Example

1
const example = (AClass: Class) => new AClass("test");

See

ReadOnlyArray

Type parameters

NameTypeDescription
Argumentsextends ReadOnlyArray = ReadOnlyArrayArguments of the class constructor.
InstanceunknownInstance of the class.

Type declaration

β€’ (...constructorArguments): Instance

Parameters
NameType
...constructorArgumentsArguments
Returns

Instance

View source


Filter

Ζ¬ Filter<Input>: Unary<Input, boolean>

Unary function that returns a boolean.

Remarks

This type is useful for cases where a function needs to check if a certain condition holds for an input value.

Example

1
const isEven: Filter<number> = number => number % 2 === 0;

See

Param

The input value to check.

Type parameters

NameDescription
InputThe type of the input value.

View source


Predicate

Ζ¬ Predicate<Input, Predicated>: (input: Input) => input is Predicated

Unary function that returns a boolean and infers a given type for its argument.

Remarks

This type is useful for cases where a function needs to check if a certain condition holds for an input value. For example, the type of a filtering function that filters strings in an array of strings and numbers could look like Predicate<string | number, string>.

Example

1
const isString: Predicate<number | string, string> = (
2
numberOrString,
3
): numberOrString is string => typeof numberOrString === "string";

Type parameters

NameTypeDescription
InputInputThe type of the input value.
Predicatedextends Input = InputThe subset of Input for which the predicate holds.

Type declaration

β–Έ (input): input is Predicated

Parameters
NameTypeDescription
inputInputThe input value to check.
Returns

input is Predicated

View source


ReadOnlyArguments

Ζ¬ ReadOnlyArguments<Input>: Input extends (…_arguments: infer Arguments) => infer _Output ? Readonly<Arguments> : never

Read-only alternative to TypeScript’s Parameters

Remarks

This type extracts the parameters of a function as a read-only tuple, similar to Parameters, but with the added benefit of making the parameters read-only.

Example

1
const example = (_foo: string, _bar: number) => undefined;
2
type ExampleArguments = ReadOnlyArguments<typeof example>; // readonly [string, number]

See

Type parameters

NameTypeDescription
Inputextends FunctionFunction to extract parameters from.

View source


Reducer

Ζ¬ Reducer<Item, Accumulator>: Unary<Item, Unary<Accumulator, Accumulator>>

Reducer/Folder function.

Remarks

Type to represent a folder/reducer unary function that takes an item and an accumulator something of the type of the accumulator.

Example

1
const reducer: Reducer<number, number> = item => accumulator =>
2
accumulator + item;

See

Unary

Type parameters

NameDescription
ItemType of the items to reduce.
AccumulatorType of the accumulator/output.

View source


Tagger

Ζ¬ Tagger<Output, Expressions>: (templateStrings: TemplateStringsArray, …expressions: Expressions) => Output

Tag function for tagged templates.

Remarks

Type to represent a tag function for tagged templates, which takes a TemplateStringArray and any number of expressions, and returns a value of type Output (string by default).

Example

1
const intParser: Tagger<number> = strings => parseInt(strings.join(""), 10);
2
intParser`100`; // 100

See

ReadOnlyArray

Type parameters

NameTypeDescription
OutputstringType of the output value.
Expressionsextends ReadOnlyArray = ReadOnlyArrayType of the expressions.

Type declaration

β–Έ (templateStrings, ...expressions): Output

Parameters
NameType
templateStringsTemplateStringsArray
...expressionsExpressions
Returns

Output

View source


Unary

Ζ¬ Unary<Input, Output>: (input: Input) => Output

Unary function.

Remarks

Type to represent a function that takes a single argument, ideal for currying.

Example

1
const unary: Unary<number, number> = number => number + 1;

See

Type parameters

NameDescription
InputType of the input value.
OutputType of the output value.

Type declaration

β–Έ (input): Output

Parameters
NameType
inputInput
Returns

Output

View source


UnaryInput

Ζ¬ UnaryInput<UnaryFunction>: UnaryFunction extends Unary<infer Input, infer _Output> ? Input : never

Unary function input type.

Remarks

This type is used to get the input type of a Unary function.

Example

1
const unary: Unary<number, string> = number => `${number}`;
2
UnaryInput<typeof unary>; // `number`

See

Unary

Type parameters

NameTypeDescription
UnaryFunctionextends Unary<never, unknown>Type of the unary function to get the input type of.

View source


UnaryOutput

Ζ¬ UnaryOutput<UnaryFunction>: UnaryFunction extends Unary<infer _Input, infer Output> ? Output : never

Unary function output type.

Remarks

This type is used to get the output type of a Unary function.

Example

1
const unary: Unary<number, string> = number => `${number}`;
2
UnaryOutput<typeof unary>; // `string`

See

Unary

Type parameters

NameTypeDescription
UnaryFunctionextends Unary<never, unknown>Type of the unary function to get the output type of.

View source

HTML

HTMLElementTagAttributeMap

Ζ¬ HTMLElementTagAttributeMap: ReadOnlyRecord<`${string}-${string}`, HTMLElementTagGlobalAttributes> & { a: HTMLElementTagGlobalAttributes & { download?: string ; href?: string ; hreflang?: string ; ping?: string ; referrerpolicy?: string ; rel?: string ; target?: string ; type?: string } ; abbr: HTMLElementTagGlobalAttributes ; address: HTMLElementTagGlobalAttributes ; area: HTMLElementTagGlobalAttributes & { accesskey?: string ; alt?: string ; coords?: string ; download?: string ; href?: string ; hreflang?: string ; ping?: string ; rel?: string ; shape?: string ; target?: string ; type?: string } ; article: HTMLElementTagGlobalAttributes ; aside: HTMLElementTagGlobalAttributes ; audio: HTMLElementTagGlobalAttributes & { autoplay?: string ; controls?: string ; crossorigin?: string ; loop?: string ; mediagroup?: string ; muted?: string ; preload?: string ; src?: string } ; b: HTMLElementTagGlobalAttributes ; base: HTMLElementTagGlobalAttributes & { href?: string ; target?: string } ; bdi: HTMLElementTagGlobalAttributes ; bdo: HTMLElementTagGlobalAttributes & { dir?: string } ; blockquote: HTMLElementTagGlobalAttributes & { cite?: string } ; body: HTMLElementTagGlobalAttributes & { alink?: string ; background?: string ; bgcolor?: string ; bottommargin?: string ; leftmargin?: string ; link?: string ; onafterprint?: string ; onbeforeprint?: string ; onbeforeunload?: string ; onblur?: string ; onerror?: string ; onfocus?: string ; onhashchange?: string ; onlanguagechange?: string ; onload?: string ; onmessage?: string ; onoffline?: string ; ononline?: string ; onpagehide?: string ; onpageshow?: string ; onpopstate?: string ; onredo?: string ; onresize?: string ; onstorage?: string ; onundo?: string ; onunload?: string ; rightmargin?: string ; text?: string ; topmargin?: string ; vlink?: string } ; br: HTMLElementTagGlobalAttributes & { clear?: string } ; button: HTMLElementTagGlobalAttributes & { autocomplete?: string ; autofocus?: string ; disabled?: string ; form?: string ; formaction?: string ; formenctype?: string ; formmethod?: string ; formnovalidate?: string ; formtarget?: string ; name?: string ; type?: string ; value?: string } ; canvas: HTMLElementTagGlobalAttributes & { height?: string ; moz-opaque?: string ; width?: string } ; caption: HTMLElementTagGlobalAttributes & { align?: string } ; cite: HTMLElementTagGlobalAttributes ; code: HTMLElementTagGlobalAttributes ; col: HTMLElementTagGlobalAttributes & { align?: string ; span?: string } ; colgroup: HTMLElementTagGlobalAttributes & { align?: string ; span?: string } ; data: HTMLElementTagGlobalAttributes & { value?: string } ; datalist: HTMLElementTagGlobalAttributes ; dd: HTMLElementTagGlobalAttributes & { nowrap?: string } ; del: HTMLElementTagGlobalAttributes & { cite?: string ; datetime?: string } ; details: HTMLElementTagGlobalAttributes & { open?: string } ; dfn: HTMLElementTagGlobalAttributes ; dialog: HTMLElementTagGlobalAttributes & { open?: string } ; div: HTMLElementTagGlobalAttributes ; dl: HTMLElementTagGlobalAttributes ; dt: HTMLElementTagGlobalAttributes ; em: HTMLElementTagGlobalAttributes ; embed: HTMLElementTagGlobalAttributes & { height?: string ; src?: string ; type?: string ; width?: string } ; fieldset: HTMLElementTagGlobalAttributes & { disabled?: string ; form?: string ; name?: string } ; figcaption: HTMLElementTagGlobalAttributes ; figure: HTMLElementTagGlobalAttributes ; footer: HTMLElementTagGlobalAttributes ; form: HTMLElementTagGlobalAttributes & { accept?: string ; accept-charset?: string ; action?: string ; autocapitalize?: string ; autocomplete?: string ; enctype?: string ; method?: string ; name?: string ; novalidate?: string ; target?: string } ; h1: HTMLElementTagGlobalAttributes ; h2: HTMLElementTagGlobalAttributes ; h3: HTMLElementTagGlobalAttributes ; h4: HTMLElementTagGlobalAttributes ; h5: HTMLElementTagGlobalAttributes ; h6: HTMLElementTagGlobalAttributes ; head: HTMLElementTagGlobalAttributes & { profile?: string } ; header: HTMLElementTagGlobalAttributes ; hgroup: HTMLElementTagGlobalAttributes ; hr: HTMLElementTagGlobalAttributes & { align?: string ; color?: string ; noshade?: string ; size?: string ; width?: string } ; html: HTMLElementTagGlobalAttributes & { manifest?: string ; version?: string ; xmlns?: string } ; i: HTMLElementTagGlobalAttributes ; iframe: HTMLElementTagGlobalAttributes & { allow?: string ; allowfullscreen?: string ; allowpaymentrequest?: string ; csp?: string ; height?: string ; importance?: string ; name?: string ; referrerpolicy?: string ; sandbox?: string ; seamless?: string ; src?: string ; srcdoc?: string ; width?: string } ; img: HTMLElementTagGlobalAttributes & { alt?: string ; crossorigin?: string ; decoding?: string ; height?: string ; importance?: string ; intrinsicsize?: string ; ismap?: string ; loading?: string ; referrerpolicy?: string ; sizes?: string ; src?: string ; srcset?: string ; usemap?: string ; width?: string } ; input: HTMLElementTagGlobalAttributes & { accept?: string ; alt?: string ; autocomplete?: string ; autofocus?: string ; checked?: string ; dirname?: string ; disabled?: string ; form?: string ; formaction?: string ; formenctype?: string ; formmethod?: string ; formnovalidate?: string ; formtarget?: string ; height?: string ; inputmode?: string ; list?: string ; max?: string ; maxlength?: string ; min?: string ; minlength?: string ; multiple?: string ; name?: string ; pattern?: string ; placeholder?: string ; readonly?: string ; required?: string ; size?: string ; src?: string ; step?: string ; type?: string ; value?: string ; width?: string } ; ins: HTMLElementTagGlobalAttributes & { cite?: string ; datetime?: string } ; kbd: HTMLElementTagGlobalAttributes ; label: HTMLElementTagGlobalAttributes & { for?: string ; form?: string } ; legend: HTMLElementTagGlobalAttributes ; li: HTMLElementTagGlobalAttributes & { type?: string ; value?: string } ; link: HTMLElementTagGlobalAttributes & { as?: string ; crossorigin?: string ; href?: string ; hreflang?: string ; importance?: string ; integrity?: string ; media?: string ; referrerpolicy?: string ; rel?: string ; sizes?: string ; title?: string ; type?: string } ; main: HTMLElementTagGlobalAttributes ; map: HTMLElementTagGlobalAttributes & { name?: string } ; mark: HTMLElementTagGlobalAttributes ; menu: HTMLElementTagGlobalAttributes ; meta: HTMLElementTagGlobalAttributes & { charset?: string ; content?: string ; http-equiv?: string ; name?: string ; scheme?: string } ; meter: HTMLElementTagGlobalAttributes & { form?: string ; high?: string ; low?: string ; max?: string ; min?: string ; optimum?: string ; value?: string } ; nav: HTMLElementTagGlobalAttributes ; noscript: HTMLElementTagGlobalAttributes ; object: HTMLElementTagGlobalAttributes & { archive?: string ; border?: string ; classid?: string ; codebase?: string ; codetype?: string ; data?: string ; declare?: string ; form?: string ; height?: string ; name?: string ; standby?: string ; tabindex?: string ; type?: string ; typemustmatch?: string ; usemap?: string ; width?: string } ; ol: HTMLElementTagGlobalAttributes & { compact?: string ; reversed?: string ; start?: string ; type?: string } ; optgroup: HTMLElementTagGlobalAttributes & { disabled?: string ; label?: string } ; option: HTMLElementTagGlobalAttributes & { disabled?: string ; label?: string ; selected?: string ; value?: string } ; output: HTMLElementTagGlobalAttributes & { for?: string ; form?: string ; name?: string } ; p: HTMLElementTagGlobalAttributes ; param: HTMLElementTagGlobalAttributes & { name?: string ; type?: string ; value?: string ; valuetype?: string } ; picture: HTMLElementTagGlobalAttributes ; pre: HTMLElementTagGlobalAttributes & { cols?: string ; width?: string ; wrap?: string } ; progress: HTMLElementTagGlobalAttributes & { max?: string ; value?: string } ; q: HTMLElementTagGlobalAttributes & { cite?: string } ; rb: HTMLElementTagGlobalAttributes ; rp: HTMLElementTagGlobalAttributes ; rt: HTMLElementTagGlobalAttributes ; ruby: HTMLElementTagGlobalAttributes ; s: HTMLElementTagGlobalAttributes ; samp: HTMLElementTagGlobalAttributes ; script: HTMLElementTagGlobalAttributes & { async?: string ; charset?: string ; crossorigin?: string ; defer?: string ; integrity?: string ; nomodule?: string ; nonce?: string ; referrerpolicy?: string ; src?: string ; text?: string ; type?: string } ; section: HTMLElementTagGlobalAttributes ; select: HTMLElementTagGlobalAttributes & { autocomplete?: string ; autofocus?: string ; disabled?: string ; form?: string ; multiple?: string ; name?: string ; required?: string ; size?: string } ; slot: HTMLElementTagGlobalAttributes & { name?: string } ; small: HTMLElementTagGlobalAttributes ; source: HTMLElementTagGlobalAttributes & { media?: string ; sizes?: string ; src?: string ; srcset?: string ; type?: string } ; span: HTMLElementTagGlobalAttributes ; strong: HTMLElementTagGlobalAttributes ; style: HTMLElementTagGlobalAttributes & { media?: string ; nonce?: string ; scoped?: string ; title?: string ; type?: string } ; sub: HTMLElementTagGlobalAttributes ; summary: HTMLElementTagGlobalAttributes ; sup: HTMLElementTagGlobalAttributes ; table: HTMLElementTagGlobalAttributes & { align?: string ; border?: string } ; tbody: HTMLElementTagGlobalAttributes & { align?: string } ; td: HTMLElementTagGlobalAttributes & { abbr?: string ; align?: string ; axis?: string ; bgcolor?: string ; colspan?: string ; headers?: string ; rowspan?: string } ; template: HTMLElementTagGlobalAttributes ; textarea: HTMLElementTagGlobalAttributes & { autocapitalize?: string ; autocomplete?: string ; autofocus?: string ; cols?: string ; dirname?: string ; disabled?: string ; form?: string ; inputmode?: string ; maxlength?: string ; minlength?: string ; name?: string ; placeholder?: string ; readonly?: string ; required?: string ; rows?: string ; spellcheck?: string ; wrap?: string } ; tfoot: HTMLElementTagGlobalAttributes & { align?: string } ; th: HTMLElementTagGlobalAttributes & { abbr?: string ; align?: string ; axis?: string ; bgcolor?: string ; colspan?: string ; headers?: string ; rowspan?: string ; scope?: string ; sorted?: string } ; thead: HTMLElementTagGlobalAttributes & { align?: string } ; time: HTMLElementTagGlobalAttributes & { datetime?: string } ; title: HTMLElementTagGlobalAttributes ; tr: HTMLElementTagGlobalAttributes & { align?: string } ; track: HTMLElementTagGlobalAttributes & { default?: string ; kind?: string ; label?: string ; src?: string ; srclang?: string } ; u: HTMLElementTagGlobalAttributes ; ul: HTMLElementTagGlobalAttributes & { compact?: string } ; var: HTMLElementTagGlobalAttributes ; video: HTMLElementTagGlobalAttributes & { autoplay?: string ; controls?: string ; crossorigin?: string ; height?: string ; loop?: string ; mediagroup?: string ; muted?: string ; poster?: string ; preload?: string ; src?: string ; width?: string } ; wbr: HTMLElementTagGlobalAttributes }

Map of HTML element tag attributes.

Remarks

If you need the type of the HTML attributes of an HTML element, this is it.

Example

1
const getAttribute =
2
<Tag extends keyof HTMLElementTagAttributeMap>(tag: Tag) =>
3
(attribute: keyof HTMLElementTagAttributeMap[Tag]) => // …

See

View source


HTMLElementTagGlobalAttributes

Ζ¬ HTMLElementTagGlobalAttributes: ReadOnlyRecord<string, string> & { accesskey?: string ; aria-activedescendant?: string ; aria-atomic?: string ; aria-autocomplete?: string ; aria-busy?: string ; aria-checked?: string ; aria-colcount?: string ; aria-colindex?: string ; aria-colspan?: string ; aria-controls?: string ; aria-current?: string ; aria-describedby?: string ; aria-details?: string ; aria-disabled?: string ; aria-dropeffect?: string ; aria-errormessage?: string ; aria-expanded?: string ; aria-flowto?: string ; aria-grabbed?: string ; aria-haspopup?: string ; aria-hidden?: string ; aria-invalid?: string ; aria-keyshortcuts?: string ; aria-label?: string ; aria-labelledby?: string ; aria-level?: string ; aria-live?: string ; aria-modal?: string ; aria-multiline?: string ; aria-multiselectable?: string ; aria-orientation?: string ; aria-owns?: string ; aria-placeholder?: string ; aria-posinset?: string ; aria-pressed?: string ; aria-readonly?: string ; aria-relevant?: string ; aria-required?: string ; aria-roledescription?: string ; aria-rowcount?: string ; aria-rowindex?: string ; aria-rowspan?: string ; aria-selected?: string ; aria-setsize?: string ; aria-sort?: string ; aria-valuemax?: string ; aria-valuemin?: string ; aria-valuenow?: string ; aria-valuetext?: string ; autocapitalize?: string ; class?: string ; contenteditable?: string ; contextmenu?: string ; dir?: string ; draggable?: string ; dropzone?: string ; exportparts?: string ; hidden?: string ; id?: string ; inputmode?: string ; is?: string ; itemid?: string ; itemprop?: string ; itemref?: string ; itemscope?: string ; itemtype?: string ; lang?: string ; onabort?: string ; onblur?: string ; oncanplay?: string ; oncanplaythrough?: string ; onchange?: string ; onclick?: string ; oncontextmenu?: string ; ondblclick?: string ; ondrag?: string ; ondragend?: string ; ondragenter?: string ; ondragleave?: string ; ondragover?: string ; ondragstart?: string ; ondrop?: string ; ondurationchange?: string ; onemptied?: string ; onended?: string ; onerror?: string ; onfocus?: string ; onformchange?: string ; onforminput?: string ; oninput?: string ; oninvalid?: string ; onkeydown?: string ; onkeypress?: string ; onkeyup?: string ; onload?: string ; onloadeddata?: string ; onloadedmetadata?: string ; onloadstart?: string ; onmousedown?: string ; onmouseenter?: string ; onmouseleave?: string ; onmousemove?: string ; onmouseout?: string ; onmouseover?: string ; onmouseup?: string ; onmousewheel?: string ; onpause?: string ; onplay?: string ; onplaying?: string ; onpointercancel?: string ; onpointerdown?: string ; onpointerenter?: string ; onpointerleave?: string ; onpointerlockchange?: string ; onpointerlockerror?: string ; onpointermove?: string ; onpointerout?: string ; onpointerover?: string ; onpointerup?: string ; onprogress?: string ; onratechange?: string ; onreadystatechange?: string ; onreset?: string ; onresize?: string ; onscroll?: string ; onseeked?: string ; onseeking?: string ; onselect?: string ; onshow?: string ; onstalled?: string ; onsubmit?: string ; onsuspend?: string ; ontimeupdate?: string ; onvolumechange?: string ; onwaiting?: string ; part?: string ; role?: string ; slot?: string ; spellcheck?: string ; style?: string ; tabindex?: string ; title?: string ; translate?: string }

Global HTML attributes.

Remarks

If you need the type of all HTML attributes, this is it.

Example

1
const getAttribute = (attribute: keyof HTMLElementTagGlobalAttributes) => // …

See

ReadOnlyRecord

View source

Iterables

IsomorphicIterable

Ζ¬ IsomorphicIterable<Item>: Readonly<AsyncIterable<Item> | Iterable<Item>>

Value might be an AsyncIterable or just an Iterable (read-only).

Remarks

Union type useful when you want to accept both AsyncIterable and Iterable values, which is generally in asynchronous functions that can loop over @@asyncIterator or @@iterator values.

Example

1
const iterable: IsomorphicIterable<number> = [1, 2, 3];
2
3
for (const item of iterable) {
4
console.log(item); // Works
5
}
6
7
for await (const item of iterable) {
8
console.log(item); // Also works
9
}

See

Type parameters

NameTypeDescription
ItemunknownType of the items in the iterable.

View source


IsomorphicIterableItem

Ζ¬ IsomorphicIterableItem<SourceIterable>: SourceIterable extends IsomorphicIterable<infer Item> ? Item : never

Type of the items of an IsomorphicIterable.

Remarks

Sometimes we have to get the item type out of an IsomorphicIterable. This type is meant to be used where inference is not an option.

Example

1
const iterable: IsomorphicIterable<number> = [1, 2, 3];
2
const item: IsomorphicIterableItem<typeof iterable> = 1;

See

IsomorphicIterable

Type parameters

NameTypeDescription
SourceIterableextends IsomorphicIterableIsomorphicIterable type to get the item type from.`

View source


IsomorphicIterableIterator

Ζ¬ IsomorphicIterableIterator<Item>: Readonly<AsyncIterableIterator<Item> | IterableIterator<Item>>

Value might be an AsyncIterableIterator or just an IterableIterator (read-only).

Remarks

This is just an read-only alternative to AsyncIterableIterator or IterableIterator to avoid unwanted mutations.

Example

1
const iterable: IsomorphicIterableIterator<number> = [1, 2, 3];

Type parameters

NameTypeDescription
ItemunknownType of the items in the AsyncIterableIterator or IterableIterator.

View source


IsomorphicIterator

Ζ¬ IsomorphicIterator<Item, Return, Next>: Readonly<AsyncIterator<Item, Return, Next> | Iterator<Item, Return, Next>>

Value might be an AsyncIterator or just an Iterator (read-only).

Remarks

This is just an read-only alternative to AsyncIterator or Iterator to avoid unwanted mutations.

Example

1
const iterator: IsomorphicIterator<number> = [1, 2, 3];

Type parameters

NameTypeDescription
ItemunknownType of the items in the AsyncIterator or Iterator.
ReturnvoidType of the return value in the AsyncIterator or Iterator.
NextvoidType of the next value in the AsyncIterator or Iterator.

View source


ReadOnlyIterable

Ζ¬ ReadOnlyIterable<Item>: Readonly<Iterable<Item>>

Read-only Iterable.

Remarks

This is just an read-only alternative to Iterable to avoid unwanted mutations.

Example

1
const test1: ReadOnlyIterable<number> = [1, 2, 3]; // ok
2
const test2: ReadOnlyIterable<string> = [1, 2, 3]; // error

Type parameters

NameTypeDescription
ItemunknownType of the items in the Iterable.

View source


ReadOnlyIterableIterator

Ζ¬ ReadOnlyIterableIterator<Item>: Readonly<IterableIterator<Item>>

Read-only IterableIterator.

Remarks

This is just an read-only alternative to IterableIterator to avoid unwanted mutations.

Type parameters

NameTypeDescription
ItemunknownType of the items in the IterableIterator.

View source


ReadOnlyIterator

Ζ¬ ReadOnlyIterator<Item, Return, Next>: Readonly<Iterator<Item, Return, Next>>

Read-only Iterator.

Remarks

This is just an read-only alternative to Iterator to avoid unwanted mutations.

Type parameters

NameTypeDescription
ItemunknownType of the items in the Iterator.
ReturnvoidType of the return value in the Iterator.
NextvoidType of the next value in the Iterator.

View source

Number

Digit

Ζ¬ Digit: Enumerate<9>

Valid digits (0 to 9).

Remarks

The idea with this type is to use it to construct others based on it, like for example Digit2 for 00 to 99.

Example

1
const numbers: Iterable<Digit> = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

See

Enumerate

View source


Enumerate

Ζ¬ Enumerate<To, Accumulator>: Accumulator["length"] extends To ? Accumulator[number] | To : Enumerate<To, […Accumulator, Accumulator["length"]]>

Union of numbers from 0 to To

Remarks

Recursively generates a type with an union of numbers from 0 to Length - 1. This has the same limit TypeScript has for recursive types.

Example

1
type From0To10 = Enumerate<10>;

Type parameters

NameTypeDescription
Toextends numberLast number of the union (starts at 0).
Accumulatorextends ReadonlyArray<number> = []Accumulator for the recursion (for internal use).

View source


MultiDigitNumberString

Ζ¬ MultiDigitNumberString: `${bigint}${bigint}`

String with more than 1 number on it.

Remarks

This type is useful when a given string will need more than one number on it.

Example

1
const test1: MultiDigitNumberString = "01"; // ok
2
const test2: MultiDigitNumberString = "1"; // error

View source


Numeric

Ζ¬ Numeric: bigint | number

Types to represent numbers.

Remarks

The Numeric type is a union of number and bigint. It is useful for cases where a value could be either a regular JavaScript number or a BigInt.

Example

1
const numericNumber: Numeric = 42;
2
const numericBigInt: Numeric = 42n;

View source


Radix

Ζ¬ Radix: Range<2, 36>

Valid radix values (from 2 to 36).

Remarks

The Radix type is useful when working with number bases other than decimal. The radix defines the base of the number system being used. For example, a binary system has a radix of 2, a decimal system has a radix of 10, and a hexadecimal system has a radix of 16. The Radix type can be used to ensure that a given radix value is within the valid range of 2 to 36.

Example

1
const binary: Radix = 2;
2
const decimal: Radix = 10;
3
const hexadecimal: Radix = 16;

See

Range

View source


Range

Ζ¬ Range<From, To>: Exclude<Enumerate<To>, Enumerate<From>> | From

Generates a range of numbers using Enumerate with given Length and omitting the first From numbers.

Remarks

This type is equivalent to an array of numbers where the first From elements are excluded and the length of the array is Length - From. The idea is to use it to generate a range of numbers from the given From, and of the given Length.

Example

1
type From5To10 = Range<5, 10>; // 5, 6, 7, 8, 9, 10

See

Enumerate

Type parameters

NameType
Fromextends number
Toextends number

View source

Object

Empty

Empty array, object or string.

Remarks

Union type of EmptyArray, EmptyRecord and EmptyString, to signify values that are empty.

Example

1
const emptyString: Empty = "";
2
const emptyArray: Empty = [];
3
const emptyRecord: Empty = {};

See

View source


EmptyRecord

Ζ¬ EmptyRecord: ReadOnlyRecord<PropertyKey, never>

Empty record (object).

Remarks

This is a type alias for an empty readonly record. Accessing properties gives undefined.

Example

1
const emptyRecord: EmptyRecord = {};

See

ReadOnlyRecord

View source


Entry

Ζ¬ Entry<Key, Value>: readonly [key: Key, value: Value]

Entry couple [key, value].

Remarks

It is a tuple of two elements, the first one being the key and the second one being the value of an object’s property.

Example

1
const entry: Entry<string, number> = ["🟒", 1];

Type parameters

NameTypeDescription
KeyPropertyKeyObject’s properties type.
ValueunknownObject’s values type.

View source


EntryKey

Ζ¬ EntryKey<Input>: Input[0]

Key of an Entry.

Remarks

Util type to get the key of an Entry.

Example

1
const entry: Entry<string, number> = ["🟒", 1];
2
const entryKey: EntryKey<typeof entry> = entry[0];

See

Entry

Type parameters

NameTypeDescription
Inputextends EntryEntry type.

View source


EntryOf

Ζ¬ EntryOf<Type>: Entry<KeyOf<Type>, ValueOf<Type>>

Object or array Entry.

Remarks

Get the Entry type out of an object or array.

Example

1
const object = {
2
"🟒": 1,
3
"🟩": 2,
4
};
5
const entries: EntryOf<typeof object> = Object.entries(object)[0];

See

Type parameters

NameTypeDescription
Typeextends objectObject or array type.

View source


EntryValue

Ζ¬ EntryValue<Input>: Input[1]

Value of an Entry.

Remarks

Util type to get the value of an Entry.

Example

1
const entry: Entry<string, number> = ["🟒", 1];
2
const entryValue: EntryValue<typeof entry> = entry[1];

See

Entry

Type parameters

NameTypeDescription
Inputextends EntryEntry type.

View source


KeyOf

Ζ¬ KeyOf<Type>: Type extends ArrayLike ? NeverFallback<Just<Exclude<Partial<Type>["length"], Type["length"]>>, number> : `${Exclude<keyof Type, symbol>}`

Generic key for either object or array.

Remarks

Type to represent the type of the key in an array or object. It automatically omits symbol keys from objects, and uses number for arrays with dynamic length.

Example

1
const array = [1, 2, 3] as const;
2
const object = { "🟒": "🟩" } as const;
3
4
const arrayKey: KeyOf<typeof array> = 0;
5
const objectKey: KeyOf<typeof object> = "🟒";

Type parameters

NameTypeDescription
Typeextends objectObject or array type.

View source


MaybeEmpty

Ζ¬ MaybeEmpty<Input>: Either<Input, Input extends ReadOnlyArray ? EmptyArray : Input extends string ? EmptyString : Input extends ReadOnlyRecord ? EmptyRecord : undefined>

Creates an union of the given type with a possible β€œempty” value.

Remarks

This type is useful to make clear that we expect a possible empty value.

Example

1
type Greet: MaybeEmpty<"Hello">; // "Hello" | ""
2
type Triple: MaybeEmpty<readonly [1, 2, 3]>; // readonly [1, 2, 3] | readonly []
3
type Foo: MaybeEmpty<{ readonly foo: "bar" }>; // { readonly foo: "bar" } | {}

See

Type parameters

NameDescription
InputType to unite with it’s empty counterpart.

View source


NotEmpty

Ζ¬ NotEmpty<Type>: Exclude<Type, Empty>

Type for a non-empty ArrayLike, object or string.

Remarks

This type is useful for cases where you want to ensure that a value is not empty. For example, if you have an array that should always have at least one element, you could type it as NotEmpty<ArrayLike<ElementType>>.

Example

1
const notEmptyString: NotEmpty<string> = "🟒";
2
const notEmptyArray: NotEmpty<ReadOnlyArray> = ["🟒", "🟩"];
3
const notEmptyRecord: NotEmpty<ReadOnlyRecord> = { "🟒": "🟩" };

See

Empty

Type parameters

NameTypeDescription
Typeextends ArrayLike | object | stringThe type to check.

View source


ReadOnlyRecord

Ζ¬ ReadOnlyRecord<Key, Value>: Readonly<Record<Key, Value>>

Read-only record.

Remarks

There’s already a native Readonly and Record type, but this type has default type parameters to make it easier to use when the type of a record is unknown.

Example

1
const record: ReadOnlyRecord<string, Array<number>> = {
2
"🟒": [1, 2, 3],
3
"🟩": [4, 5, 6],
4
};
5
record["🟒"][0] = 7; // Error

Type parameters

NameTypeDescription
Keyextends PropertyKey = PropertyKeyType of the keys in the record.
ValueunknownType of the values in the record.

View source


ValueOf

Ζ¬ ValueOf<Type>: KeyOf<Type> extends keyof Type ? Type[KeyOf<Type>] : never

Generic key for either object or array.

Remarks

This type is used to get the type of the values in a collection (items of an ArrayLike or properties of a Record).

Example

1
const object = {
2
"🟒": 1,
3
"🟩": 2,
4
};
5
const key: ValueOf<typeof object> = 1;

See

KeyOf

Type parameters

NameTypeDescription
Typeextends objectObject or array type.

View source

RegExp

RegularExpression

Ζ¬ RegularExpression: `/${string}/${RegularExpressionFlags}`

String representing a regular expression.

Remarks

Safer than string and simpler than RegExp type to represent a regular expression. It RegularExpression to enforce flags to always have u and have a consistent order.

Example

1
const regex: RegularExpression = "/^[a-z]+$/u";

See

View source


RegularExpressionFlags

Ζ¬ RegularExpressionFlags: `${MaybeEmpty<β€œg”>}${MaybeEmpty<β€œi”>}${MaybeEmpty<β€œm”>}${MaybeEmpty<β€œs”>}u`

Possible combinations of regular expression flags (with mandatory u flag).

Remarks

Type union stricter than string type for RegExp flags. The unicode flag is mandatory to ensure unicode characters are always supported.

Example

1
const flags1: RegularExpressionFlags = "u";
2
const flags2: RegularExpressionFlags = "gu";
3
const flags3: RegularExpressionFlags = "iu";
4
const flags4: RegularExpressionFlags = "giu";

See

Regular Expressions

View source

String

Empty

Empty array, object or string.

Remarks

Union type of EmptyArray, EmptyRecord and EmptyString, to signify values that are empty.

Example

1
const emptyString: Empty = "";
2
const emptyArray: Empty = [];
3
const emptyRecord: Empty = {};

See

View source


EmptyString

Ζ¬ EmptyString: typeof EMPTY_STRING

Empty string.

Remarks

This type is a string with no characters on it (length 0). EmptyString.

Example

1
const emptyString: EmptyString = "";

View source


Head

Ζ¬ Head<Input>: HeadAndTail<Input>[0]

Initial value of an ArrayLike.

Remarks

Given a type argument (an ArrayLike), this returns the type of the item in index 0.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const head: Head<typeof array> = "🟒";

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeArrayLike value (such as Array or string).

View source


HeadAndTail

Ζ¬ HeadAndTail<Input>: Input extends readonly [head: infer HeadItem, tail: infer TailItems] ? readonly [head: HeadItem, tail: TailItems] : Input extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [head: FirstCharacter, tail: RestOfString] : Input extends EmptyArray | EmptyString ? readonly [head: undefined, tail: Input] : readonly [head: Maybe<Input[number]>, tail: Input]

Get a couple with the head and tail types of an ArrayLike.

Remarks

Given a type argument (an ArrayLike), this returns a couple with the type of the item in index 0 first, and the rest of the ArrayLike after.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const headAndTail: HeadAndTail<typeof array> = ["🟒", ["🟩", "πŸ’š"]];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeInput ArrayLike.

View source


Initial

Ζ¬ Initial<Input>: InitialAndLast<Input>[0]

Initial values of an ArrayLike (omitting the last).

Remarks

Given a type argument (an ArrayLike), this returns the type of the items from the start of the ArrayLike until the before to last item.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const initial: Initial<typeof array> = ["🟒", "🟩"];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeArrayLike value (such as Array or string).

View source


InitialAndLast

Ζ¬ InitialAndLast<Input>: Input extends readonly […(infer InitialItems), infer LastItem] ? readonly [initial: InitialItems, last: LastItem] : Input extends EmptyArray | EmptyString ? readonly [initial: Input, last: undefined] : Input extends `${infer FirstCharacter}${infer RestOfString}` ? readonly [initial: `${RestOfString extends EmptyString ? EmptyString : FirstCharacter}${Head<InitialAndLast<RestOfString>>}`, last: `${RestOfString extends EmptyString ? FirstCharacter : Last<RestOfString>}`] : readonly [initial: Input, last: Maybe<Input[number]>]

Get a couple with the initial and last types of an ArrayLike.

Remarks

Given a ArrayLike, this returns a couple with the type of all items from the start until the item before last, and then the last.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const initialAndLast: InitialAndLast<typeof array> = [["🟒", "🟩"], "πŸ’š"];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeInput ArrayLike.

View source


Last

Ζ¬ Last<Input>: InitialAndLast<Input>[1]

Last value of an ArrayLike.

Remarks

Type of the last character of a string or the last element of an array.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const last: Last<typeof array> = "πŸ’š";

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeThe input ArrayLike.

View source


LocaleIdentifier

Ζ¬ LocaleIdentifier: "eo" | "yue-Hant-HK" | LocaleString<"af", `${β€œN” | β€œZ”}A`> | LocaleString<"ak", "GH"> | LocaleString<"am", "ET"> | LocaleString<"ar", `${β€œA” | β€œY”}E` | "BH" | "DZ" | `E${β€œG” | β€œH” | β€œR”}` | `I${β€œL” | β€œQ”}` | "JO" | "KW" | `I${β€œB” | β€œY”}` | `M${β€œA” | β€œR”}` | "OM" | "PS" | "QA" | `S${β€œA” | β€œD” | β€œO” | β€œS” | β€œY”}` | `T${β€œD” | β€œN”}`> | LocaleString<"as", "IN"> | LocaleString<"asa", "TZ"> | LocaleString<"az", LocaleString<"Cyrl" | "Latn", "AZ">> | LocaleString<"be", "BY"> | LocaleString<"bem", "ZM"> | LocaleString<"bez", "TZ"> | LocaleString<"bg", "BG"> | LocaleString<"bm", "ML"> | LocaleString<"bn", "BD" | "IN"> | LocaleString<"bo", `${β€œC” | β€œI”}N`> | LocaleString<"bs", "BA"> | LocaleString<"ca", "ES"> | LocaleString<"cgg", "UG"> | LocaleString<"chr", "US"> | LocaleString<"cs", "CZ"> | LocaleString<"cy", "GB"> | LocaleString<"da", "DK"> | LocaleString<"dav", "KE"> | LocaleString<"de", "AT" | `${β€œB” | β€œD”}E` | "CH" | `L${β€œI” | β€œU”}`> | LocaleString<"ebu", "KE"> | LocaleString<"ee", "GH" | "TG"> | LocaleString<"el", "CY" | "GR"> | LocaleString<"en", `A${β€œS” | β€œU”}` | `B${β€œE” | β€œW” | β€œZ”}` | "CA" | `G${β€œB” | β€œU”}` | "HK" | "IE" | `I${β€œL” | β€œN”}` | "JM" | `M${β€œH” | β€œP” | β€œT” | β€œU”}` | `N${β€œA” | β€œZ”}` | `P${β€œH” | β€œK”}` | "SG" | "TT" | `U${β€œM” | β€œS”}` | "VI" | `Z${β€œA” | β€œW”}`> | LocaleString<"es", "419" | "AR" | "BO" | `C${β€œL” | β€œO” | β€œR”}` | "DO" | `E${β€œC” | β€œS”}` | `G${β€œQ” | β€œT”}` | "HN" | "MX" | "NI" | `P${β€œA” | β€œE” | β€œR” | β€œY”}` | "SV" | `U${β€œS” | β€œY”}` | "VE"> | LocaleString<"et", "EE"> | LocaleString<"eu", "ES"> | LocaleString<"fa", "AF" | "IR"> | LocaleString<"ff", "SN"> | LocaleString<"fi", "FI"> | LocaleString<"fil", "PH"> | LocaleString<"fo", "FO"> | LocaleString<"fr", `B${β€œE” | β€œF” | β€œI” | β€œJ” | β€œL”}` | `C${β€œA” | β€œD” | β€œF” | β€œG” | β€œH” | β€œI” | β€œM”}` | "DJ" | "FR" | `G${β€œA” | β€œN” | β€œP” | β€œQ”}` | "KM" | "LU" | `M${β€œC” | β€œF” | β€œG” | β€œL” | β€œQ”}` | "NE" | `R${β€œE” | β€œW”}` | "SN" | `T${β€œD” | β€œG”}`> | LocaleString<"ga", "IE"> | LocaleString<"gl", "ES"> | LocaleString<"gsw", "CH"> | LocaleString<"gu", "IN"> | LocaleString<"guz", "KE"> | LocaleString<"gv", "GB"> | LocaleString<"ha", LocaleString<"Latn", "GH" | `N${β€œE” | β€œG”}`>> | LocaleString<"haw", "US"> | LocaleString<"he", "IL"> | LocaleString<"hi", "IN"> | LocaleString<"hr", "HR"> | LocaleString<"hu", "HU"> | LocaleString<"hy", "AM"> | LocaleString<"id", "ID"> | LocaleString<"ig", "NG"> | LocaleString<"ii", "CN"> | LocaleString<"is", "IS"> | LocaleString<"it", "CH" | "IT"> | LocaleString<"ja", "JP"> | LocaleString<"jmc", "TZ"> | LocaleString<"ka", "GE"> | LocaleString<"kab", "DZ"> | LocaleString<"kam", "KE"> | LocaleString<"kde", "TZ"> | LocaleString<"kea", "CV"> | LocaleString<"khq", "ML"> | LocaleString<"ki", "KE"> | LocaleString<"kk", LocaleString<"Cyrl", "KZ">> | LocaleString<"kl", "GL"> | LocaleString<"kln", "KE"> | LocaleString<"km", "KH"> | LocaleString<"kn", "IN"> | LocaleString<"ko", "KR"> | LocaleString<"kok", "IN"> | LocaleString<"kw", "GB"> | LocaleString<"lag", "TZ"> | LocaleString<"lg", "UG"> | LocaleString<"lt", "LT"> | LocaleString<"luo", "KE"> | LocaleString<"luy", "KE"> | LocaleString<"lv", "LV"> | LocaleString<"mas", "KE" | "TZ"> | LocaleString<"mer", "KE"> | LocaleString<"mfe", "MU"> | LocaleString<"mg", "MG"> | LocaleString<"mk", "MK"> | LocaleString<"ml", "IN"> | LocaleString<"mr", "IN"> | LocaleString<"ms", "BN" | "MY"> | LocaleString<"mt", "MT"> | LocaleString<"my", "MM"> | LocaleString<"naq", "NA"> | LocaleString<"nb", "NO"> | LocaleString<"nd", "ZW"> | LocaleString<"ne", "IN" | "NP"> | LocaleString<"nl", "BE" | "NL"> | LocaleString<"nn", "NO"> | LocaleString<"nyn", "UG"> | LocaleString<"om", "ET" | "KE"> | LocaleString<"or", "IN"> | LocaleString<"pa", LocaleString<"Arab", "PK"> | LocaleString<"Guru", "IN">> | LocaleString<"pl", "PL"> | LocaleString<"ps", "AF"> | LocaleString<"pt", "BR" | "GW" | "MZ" | "PT"> | LocaleString<"rm", "CH"> | LocaleString<"ro", "MD" | "RO"> | LocaleString<"rof", "TZ"> | LocaleString<"ru", "MD" | "RU" | "UA"> | LocaleString<"rw", "RW"> | LocaleString<"rwk", "TZ"> | LocaleString<"saq", "KE"> | LocaleString<"seh", "MZ"> | LocaleString<"ses", "ML"> | LocaleString<"sg", "CF"> | LocaleString<"shi", LocaleString<"Latn" | "Tfng", "MA">> | LocaleString<"si", "LK"> | LocaleString<"sk", "SK"> | LocaleString<"sl", "SI"> | LocaleString<"sn", "ZW"> | LocaleString<"so", "DJ" | "ET" | "KE" | "SO"> | LocaleString<"sq", "AL"> | LocaleString<"sr", LocaleString<"Cyrl" | "Latn", "BA" | "ME" | "RS">> | LocaleString<"sv", "FI" | "SE"> | LocaleString<"sw", "KE" | "TZ"> | LocaleString<"ta", "IN" | "LK"> | LocaleString<"te", "IN"> | LocaleString<"teo", "KE" | "UG"> | LocaleString<"th", "TH"> | LocaleString<"ti", `E${β€œR” | β€œT”}`> | LocaleString<"to", "TO"> | LocaleString<"tr", "TR"> | LocaleString<"tzm", LocaleString<"Latn", "MA">> | LocaleString<"uk", "UA"> | LocaleString<"ur", "IN" | "PK"> | LocaleString<"uz", LocaleString<"Arab", "AF"> | LocaleString<"Cyrl" | "Latn", "UZ">> | LocaleString<"vi", "VN"> | LocaleString<"vun", "TZ"> | LocaleString<"xog", "UG"> | LocaleString<"yo", "NG"> | LocaleString<"zh", LocaleString<`Han${β€œs” | β€œt”}`, "HK" | "MO"> | LocaleString<"Hans", "CN" | "SG"> | LocaleString<"Hant", "TW">> | LocaleString<"zu", "ZA">

Locale identifiers (language-country).

Remarks

When using i18n tools, this is a stricter union type than string to handle the locale identifiers.

Example

1
const locale: LocaleIdentifier = "en-US";

See

EmptyString

View source


LocaleString

Ζ¬ LocaleString<LanguageCode, CountryCodes, Separator>: `${LanguageCode}${MaybeEmpty<`${Separator}${CountryCodes}`>}`

String for locales such as β€œen-US”.

Remarks

This type mainly exists to make LocaleIdentifier a little bit easier to the eyes.

Example

1
type English1: LocaleIdentifier<"en", "US" | "UK">; // "en" | "en-US" | "en-UK"
2
type English2: LocaleIdentifier<"en", "US" | "UK", "_">; // "en" | "en_US" | "en_UK"

See

LocaleIdentifier

Type parameters

NameTypeDescription
LanguageCodeextends MultiCharacterString2 character language code.
CountryCodesextends MultiCharacterStringUnion of country codes.
Separatorextends "-" | "_" = "-"-

View source


MaybeEmpty

Ζ¬ MaybeEmpty<Input>: Either<Input, Input extends ReadOnlyArray ? EmptyArray : Input extends string ? EmptyString : Input extends ReadOnlyRecord ? EmptyRecord : undefined>

Creates an union of the given type with a possible β€œempty” value.

Remarks

This type is useful to make clear that we expect a possible empty value.

Example

1
type Greet: MaybeEmpty<"Hello">; // "Hello" | ""
2
type Triple: MaybeEmpty<readonly [1, 2, 3]>; // readonly [1, 2, 3] | readonly []
3
type Foo: MaybeEmpty<{ readonly foo: "bar" }>; // { readonly foo: "bar" } | {}

See

Type parameters

NameDescription
InputType to unite with it’s empty counterpart.

View source


MultiCharacterString

Ζ¬ MultiCharacterString: `${string}${string}`

String with more than 1 character on it.

Deprecated

Not actually deprecated, this type doesn’t do anything yet.

Remarks

This type will be useful when a given string will need more than one character on it. Sadly this type doesn’t work because TypeScript considers "" a string, so "" + "" === string, same for "f" + "" which is not a multi character string.

Example

1
const test1: MultiCharacterString = "foo"; // ok
2
const test2: MultiCharacterString = "f"; // error

View source


MultiDigitNumberString

Ζ¬ MultiDigitNumberString: `${bigint}${bigint}`

String with more than 1 number on it.

Remarks

This type is useful when a given string will need more than one number on it.

Example

1
const test1: MultiDigitNumberString = "01"; // ok
2
const test2: MultiDigitNumberString = "1"; // error

View source


NotEmpty

Ζ¬ NotEmpty<Type>: Exclude<Type, Empty>

Type for a non-empty ArrayLike, object or string.

Remarks

This type is useful for cases where you want to ensure that a value is not empty. For example, if you have an array that should always have at least one element, you could type it as NotEmpty<ArrayLike<ElementType>>.

Example

1
const notEmptyString: NotEmpty<string> = "🟒";
2
const notEmptyArray: NotEmpty<ReadOnlyArray> = ["🟒", "🟩"];
3
const notEmptyRecord: NotEmpty<ReadOnlyRecord> = { "🟒": "🟩" };

See

Empty

Type parameters

NameTypeDescription
Typeextends ArrayLike | object | stringThe type to check.

View source


Tagger

Ζ¬ Tagger<Output, Expressions>: (templateStrings: TemplateStringsArray, …expressions: Expressions) => Output

Tag function for tagged templates.

Remarks

Type to represent a tag function for tagged templates, which takes a TemplateStringArray and any number of expressions, and returns a value of type Output (string by default).

Example

1
const intParser: Tagger<number> = strings => parseInt(strings.join(""), 10);
2
intParser`100`; // 100

See

ReadOnlyArray

Type parameters

NameTypeDescription
OutputstringType of the output value.
Expressionsextends ReadOnlyArray = ReadOnlyArrayType of the expressions.

Type declaration

β–Έ (templateStrings, ...expressions): Output

Parameters
NameType
templateStringsTemplateStringsArray
...expressionsExpressions
Returns

Output

View source


Tail

Ζ¬ Tail<Input>: HeadAndTail<Input>[1]

Last values of an ArrayLike (omitting the first).

Remarks

Type of the last items of an ArrayLike, excluding the first item in said ArrayLike.

Example

1
const array = ["🟒", "🟩", "πŸ’š"];
2
const tail: Tail<typeof array> = ["🟩", "πŸ’š"];

See

Type parameters

NameTypeDescription
Inputextends ArrayLikeType of the array to get the tail.

View source