Recursively generates the result of adding Addend
to Augend
.
Gets the possible index values of a ReadonlyArrayLike
, and fallbacks
to number
when it can't be inferred.
A value that might be coming from a Promise
or might not, but can be
await
ed. This type is specially useful when a code is "isomorphic
asynchronous", meaning it will handle both the asynchronous and synchronous
version of the same type.
Awaitable effect function.
Union of AsyncGenerator
and Generator
.
Union of AsyncIterable
and Iterable
. This type is useful when we want to
accept both AsyncIterable
and Iterable
values, which is generally in
asynchronous functions that can loop over
@@asyncIterator or
@@iterator values.
Union of AsyncIterableIterator
and IterableIterator
.
Union of AsyncIterator
and Iterator
.
This type is a generic constructor function, mainly used when taking a class as an argument.
Day of the month values in numeric format (from 1
to 31
).
Day of the week values in numeric format (from 0
to 6
).
Valid digits (0
to 9
).
Effect function.
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.
Readonly empty array. Trying to access items on it will give a compile-time error.
Empty string. This type is a string with no characters on it (length 0
).
Couple (tuple of two items) that represents an object entry. The first item
represents the Key
and the second the Value
of the property.
Key of an Entry
.
Get the Entry
of the passed object.
Value of an Entry
.
Recursively generates a type with an union of numbers from 0
to To
.
Type fallback helper. Takes a Wrong
, a MaybeWrong
and a FallbackType
.
If MaybeWrong
extends Wrong
, then Fallback
returns FallbackType
, if
not then it just returns MaybeWrong
.
Types that evaluates to false
. Due to TypeScript type limitations NaN
can't be included.
Unary function that returns a boolean
, useful for cases where a function
needs to check if a certain condition holds for an input value.
Initial value (item in index 0
) of a ReadonlyArrayLike
.
Get a couple with the head (item at index 0
) and tail (all elements except
index 0
) types of an ReadonlyArrayLike
.
Hours values in numeric format (from 0
to 23
).
Recursively generates an Array type with the given length.
Initial values of an ReadonlyArrayLike
(all items except the last).
Get a couple with the initial and last types of an ReadonlyArrayLike
.
The first item has all elements except the last, and the second item has
the last element.
ISO 8601 format of a date (returned
by Date#toISOString). It uses
MinimumLengthNumberString
because the type complexity using better
types would be too hight (32,140,800,000 union types approximately).
Day of the month values in string format ("01"
to "31"
).
Hours values in string format (from "00"
to "23"
).
ISO milliseconds values in string format (from "000"
to "999"
).
ISO minutes values in string format (from "00"
to "59"
).
ISO Month values in string format (from "01"
to "12"
).
ISO seconds values in string format (from "00"
to "59"
).
ISO year values in string format.
Type of the items of an AwaitableIterable
.
Gets the type of the items in an AwaitableIterator
.
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.
Excludes undefined
of a type union. Similar to NonNullable
but ignoring
null
.
Key of objects (stringified like Object.entries
does).
ISO 639 language codes.
BCP 47 Language Tag. When using i18n tools, this is a stricter union type
than string
to handle the locale identifiers.
Last item of an ReadonlyArrayLike
.
Value that could be undefined
.
ISO milliseconds values in number format (from 0
to 999
).
String with more than 1 number on it. This type is useful when a given string will need more than one number on it.
ISO minutes values in number format (from 0
to 59
).
ISO Month values in number format (from 0
to 11
).
Takes a type that could be never
and replaces the never
case with the
given fallback type. This works like the the ??
operator, but for the
never
type.
Nullish value (union of null
and undefined
).
Union of bigint
and number
.
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>
.
Union of all JavaScript primitive types.
Valid radix values (from 2
to 36
). Useful for parseInt
type of
functions.
Generates a range of numbers using Enumerate
from From
to To
.
An alternative for TypeScript's ReadonlyArray
type, with its type set to
unknown
by default to avoid the using the awkward ReadonlyArray<unknown>
every time for generic typed read0only arrays.
Shallow read-only ArrayLike
alternative with optional item type and
configurable length
. This type is similar to doing
Readonly<ArrayLike<unknown>>
, with some key differences:
Read-only record. This is similar to doing Readonly<Record<Key, Value>>
,
but with two differences:
Read-only version of TemplateStringsArray
.
Type union stricter than string
type for RegExp flags. The unicode flag is
mandatory to ensure unicode characters are always supported.
Intersection that replaces properties in the Original
type with the onces
in Replacements
.
ISO seconds values in number format (from 0
to 59
).
Tuple of length 1 (AKA Monuple).
Values that can be stringified.
Joins all the items of the given stringable array using the given "glue".
Supported structures for structuredClone
Tag function for tagged templates.
All items of a ReadonlyArrayLike
except the last.
Possible type values returned by typeof
, including the proposed but never
added type "null"
for null
.
Unary function, meaning a function that takes a single argument, ideal for currying.
Takes a value that could be undefined
, and if it is undefined
it goes to
the Fallback
value.
Type of property values in an object (also works for items in an
ReadonlyArrayLike
).