Skip to main content

Built and signed on GitHub Actions

🏷️ Collection of TypeScript types.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 weeks ago (0.3.3)
T
Add

Recursively generates the result of adding Addend to Augend.

T
ArrayLikeIndexFallback

Gets the possible index values of a ReadonlyArrayLike, and fallbacks to number when it can't be inferred.

T
Awaitable

A value that might be coming from a Promise or might not, but can be awaited. 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.

T
AwaitableEffect

Awaitable effect function.

T
AwaitableGenerator

Union of AsyncGenerator and Generator.

T
AwaitableIterable

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.

T
AwaitableIterableIterator

Union of AsyncIterableIterator and IterableIterator.

T
AwaitableIterator

Union of AsyncIterator and Iterator.

T
Class

This type is a generic constructor function, mainly used when taking a class as an argument.

T
DayOfMonth

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

T
DayOfWeek

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

T
Digit

Valid digits (0 to 9).

T
Effect

Effect function.

T
Either

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.

T
EmptyArray

Readonly empty array. Trying to access items on it will give a compile-time error.

T
EmptyString

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

T
Entry

Couple (tuple of two items) that represents an object entry. The first item represents the Key and the second the Value of the property.

T
EntryKey

Key of an Entry.

T
EntryOf

Get the Entry of the passed object.

T
EntryValue

Value of an Entry.

T
Enumerate

Recursively generates a type with an union of numbers from 0 to To.

T
Fallback

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.

T
Falsy

Types that evaluates to false. Due to TypeScript type limitations NaN can't be included.

T
Filter

Unary function that returns a boolean, useful for cases where a function needs to check if a certain condition holds for an input value.

T
Head

Initial value (item in index 0) of a ReadonlyArrayLike.

T
HeadAndTail

Get a couple with the head (item at index 0) and tail (all elements except index 0) types of an ReadonlyArrayLike.

T
Hours

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

T
IndexArray

Recursively generates an Array type with the given length.

T
Initial

Initial values of an ReadonlyArrayLike (all items except the last).

T
InitialAndLast

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.

T
ISODate

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).

T
ISODayOfMonth

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

T
ISOHours

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

T
ISOMilliseconds

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

T
ISOMinutes

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

T
ISOMonth

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

T
ISOSeconds

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

T
ISOYear

ISO year values in string format.

T
IterableItem

Type of the items of an AwaitableIterable.

T
IteratorItem

Gets the type of the items in an AwaitableIterator.

T
JSONValue

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.

T
Just

Excludes undefined of a type union. Similar to NonNullable but ignoring null.

T
KeyOf

Key of objects (stringified like Object.entries does).

T
LanguageCode

ISO 639 language codes.

T
LanguageTag

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

T
Last

Last item of an ReadonlyArrayLike.

T
Maybe

Value that could be undefined.

T
Milliseconds

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

T
MinimumLengthNumberString

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

T
Minutes

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

T
Month

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

T
NeverFallback

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.

T
Nullish

Nullish value (union of null and undefined).

T
Numeric

Union of bigint and number.

T
Predicate

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>.

T
Primitive

Union of all JavaScript primitive types.

T
Radix

Valid radix values (from 2 to 36). Useful for parseInt type of functions.

T
Range

Generates a range of numbers using Enumerate from From to To.

T
ReadonlyArray

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.

T
ReadonlyArrayLike

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:

T
ReadonlyRecord

Read-only record. This is similar to doing Readonly<Record<Key, Value>>, but with two differences:

T
ReadonlyTemplateStringsArray

Read-only version of TemplateStringsArray.

T
RegularExpressionFlags

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

T
Replace

Intersection that replaces properties in the Original type with the onces in Replacements.

T
Seconds

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

T
Single

Tuple of length 1 (AKA Monuple).

T
Stringable

Values that can be stringified.

T
StringJoin

Joins all the items of the given stringable array using the given "glue".

T
StructuredData

Supported structures for structuredClone

T
Tagger

Tag function for tagged templates.

T
Tail

All items of a ReadonlyArrayLike except the last.

T
TypeOfDictionary

typeof dictionary, including the proposed but never added type "null" for null.

T
TypeOfValue

Possible type values returned by typeof, including the proposed but never added type "null" for null.

T
Unary

Unary function, meaning a function that takes a single argument, ideal for currying.

T
UndefinedFallback

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

T
ValueOf

Type of property values in an object (also works for items in an ReadonlyArrayLike).