A collection of essential TypeScript types
Browse by type
<img src="https://github.com/sindresorhus/type-fest/raw/v6.0.3/media/logo.svg" alt="type-fest" height="300">
<b>A collection of essential TypeScript types</b>
Many of the types here should have been built-in. You can help by suggesting some of them to the TypeScript project.
Either add this package as a dependency or copy-paste the needed types. No credit required. 👌
PR welcome for additional commonly needed types and docs improvements. Read the contributing guidelines first.
Help wanted with reviewing proposals and pull requests.
npm install type-fest
Requires TypeScript >=6, ESM, and {strict: true} in your tsconfig.
{exactOptionalPropertyTypes: true} is required. Disabling it is unsupported.
[!NOTE] This readme shows the current development version. For docs about the latest version, see the npm page.
You may also like my ts-extras package which provides runtime functions for some of these types.
import type {Except} from 'type-fest';
type Foo = {
unicorn: string;
rainbow: boolean;
};
type FooWithoutRainbow = Except<Foo, 'rainbow'>;
//=> {unicorn: string}
Try it in the TypeScript Playground
Click the type names for complete docs.
Primitive - Matches any primitive value.Class - Matches a class.Constructor - Matches a class constructor.AbstractClass - Matches an abstract class.AbstractConstructor - Matches an abstract class constructor.AsyncFunction - Matches an asynchronous function.AnyAsyncFunction - Matches any asynchronous function.AnyFunction - Matches any function.TypedArray - Matches any typed array, like Uint8Array or Float64Array.ReadonlyDate - Matches a Date that cannot be changed.ObservableLike - Matches a value that is like an Observable.LowercaseLetter - Matches any lowercase letter in the basic Latin alphabet (a-z).UppercaseLetter - Matches any uppercase letter in the basic Latin alphabet (A-Z).DigitCharacter - Matches any digit as a string ('0'-'9').Alphanumeric - Matches any lowercase letter (a-z), uppercase letter (A-Z), or digit ('0'-'9') in the basic Latin alphabet.EmptyObject - Represents a strictly empty plain object, the {} value.NonEmptyObject - Represents an object with at least 1 non-optional key.UnknownRecord - Represents an object with unknown value. You probably want this instead of {}.UnknownArray - Represents an array with unknown value.UnknownMap - Represents a map with unknown key and value.UnknownSet - Represents a set with unknown value.UnknownCollection - Matches an array, map, or set, including readonly and weak variants.Except - Create a type from an object type without certain keys.Writable - Create a type that strips readonly from the given type. Inverse of Readonly<T>.WritableDeep - Create a deeply mutable version of an object/ReadonlyMap/ReadonlySet/ReadonlyArray type. The inverse of ReadonlyDeep<T>. Use Writable<T> if you only need one level deep.Merge - Merge two types into a new type. Keys of the second type override keys of the first type.MergeAll - Merge any number of types into a new type. Keys of each type override keys of the types before it.ObjectMerge - Merge two object types into a new object type, where keys from the second override keys from the first.MergeDeep - Merge two objects or two arrays/tuples recursively into a new type.MergeExclusive - Create a type that has mutually exclusive keys.Modify - Create a type from an object type and a modifier type, where keys of the modifier type override keys of the object type, and keys with the never type are removed from the result.ModifyDeep - Recursively create a type from an object type and a modifier type, where keys of the modifier type override keys of the object type, and keys with the never type are removed from the result.OverrideProperties - Override existing properties of the given type. Similar to Merge, but enforces that the original type has the properties you want to override.OverridePropertiesDeep - Override existing properties of the given type deeply. Similar to MergeDeep, but requires overridden keys to exist at every level.RenameKeys - Rename keys in an object type according to a map of old-to-new names.RequireAtLeastOne - Create a type that requires at least one of the given keys, while keeping the remaining keys as is.RequireExactlyOne - Create a type that requires exactly one of the given keys and disallows more, while keeping the remaining keys as is.RequireAllOrNone - Create a type that requires all of the given keys or none of the given keys, while keeping the remaining keys as is.RequireOneOrNone - Create a type that requires exactly one of the given keys or none of the given keys, while keeping the remaining keys as is.RequireNone - Create an object type that forbids the given keys, to intersect with another object type.SingleKeyObject - Create a type that only accepts an object with a single key.RequiredDeep - Create a deeply required version of another type.RequiredKeepUndefined - Create a type that makes all keys required, while the keys that were optional also accept undefined.RequiredNonNullable - Create a type that makes all keys required and non-nullable, including the elements of an array or tuple.PickDeep - Pick properties from a deeply-nested object.OmitDeep - Omit properties from a deeply-nested object.OmitIndexSignature - Omit any index signatures from the given object type, leaving only explicitly defined properties.PickIndexSignature - Pick only index signatures from the given object type, leaving out all explicitly defined properties.PickWritable - Pick only the writable properties from the given object type, leaving out the readonly ones.PickReadonly - Pick only the readonly properties from the given object type, leaving out the writable ones.PickNonNever - Pick only the properties of the given object type that do not have the never type.PartialDeep - Create a deeply optional version of another type.UndefinedToOptional - Make properties with a union containing undefined optional, removing undefined from their values.PartialOnUndefined - Create a type where all keys accepting undefined type are set to optional.PartialOnUndefinedDeep - Create a deep version of another type where all keys accepting undefined type are set to optional.UndefinedOnPartial - Create a type where all optional keys are set to also accept undefined.UndefinedOnPartialDeep - Create a deep version of another type where all optional keys are set to also accept undefined.UndefinableDeep - Create a deep version of another type where leaf values also accept undefined, keeping object containers present.UnwrapPartial - Revert the Partial modifier on an object type.UnwrapRequired - Revert the Required modifier on an object type.ReadonlyDeep - Create a deeply immutable version of another type.LiteralUnion - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.ExtractLiterals - Extract the literal types from a union, removing wide types like string and infinite string types like `on${string}`.CollapseLiterals - Collapse literal union members into broader types already present in the union.Flavor - Attach a name to a type without requiring a cast, so that differently named types cannot be mixed.Tagged - Create a tagged type that can support multiple tags and per-tag metadata.UnwrapTagged - Get the untagged portion of a tagged type created with Tagged.UnwrapBrandedPrimitive - Remove brand properties from primitive types while preserving literal types.GetTagMetadata - Given a type and a tag name, returns the metadata associated with that tag on that type.InvariantOf - Create an invariant type, which is a type that does not accept supertypes and subtypes.SetOptional - Create a type that makes the given keys optional, while keeping the remaining keys as is.SetOptionalDeep - Create a type that makes the given keys optional, with support for deeply nested key paths, while keeping the remaining keys as is.SetOptionalExcept - Create a type that makes all keys optional except the given keys, which are kept as is.SetReadonly - Create a type that makes the given keys readonly, while keeping the remaining keys as is.SetRequired - Create a type that makes the given keys required, while keeping the remaining keys as is.SetRequiredDeep - Create a type that makes the given keys required, with support for deeply nested key paths, while keeping the remaining keys as is.SetRequiredExcept - Create a type that makes all keys required except the given keys, which are kept as is.SetRequiredNonNullable - Create a type that makes the given keys required and non-nullable, while keeping the remaining keys as is.SetNullable - Create a type that makes the given keys nullable, while keeping the remaining keys as is.SetNonNullable - Create a type that makes the given keys non-nullable, while keeping the remaining keys as is.SetNonNullableDeep - Create a type that makes the specified keys non-nullable (removes `$ claude mcp add --transport http codehub https://codehub.bot/mcp
One hosted endpoint, no key: your agent can search, read and trace sindresorhus/type-fest and every other graph here. Cursor, Windsurf and other clients →