MCPcopy Create free account
hub / github.com/sindresorhus/type-fest

github.com/sindresorhus/type-fest

Chat with this repo
repository ↗ · DeepWiki ↗ · release v6.0.3 ↗ · + Follow · compare 6 versions

A collection of essential TypeScript types

2,026 symbols 2,925 edges 673 files ⚖ CC 4 documented · 0% ● updated 4d agolatest release v6.0.3 · 2026-11-19★ 17,5743 open issues

Browse by type

⨍ Functions 1,157◇ Types & classes 869
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<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>

npm dependents npm downloads

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.

Install

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.

Usage

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

API

Click the type names for complete docs.

Basic

Utilities

  • 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 `

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 1,065
Class 461
Enum 244
Interface 164
Method 92

Languages

TypeScript100%

Modules by API surface

test-d/jsonifiable-value.ts135 symbols
test-d/as-extendable.ts69 symbols
test-d/exact.ts61 symbols
test-d/jsonify.ts41 symbols
test-d/merge-deep.ts39 symbols
test-d/undefined-to-optional.ts33 symbols
test-d/property-value.ts26 symbols
test-d/abstract-class.ts26 symbols
test-d/partial-deep.ts25 symbols
test-d/is-record-like.ts24 symbols
test-d/class.ts24 symbols
test-d/readonly-deep.ts23 symbols

Dependencies from manifests, versioned · 12 of 14, runtime first

tagged-tag1.0.0 · 1×
@typescript/vfs1.6.6 · 1×
dedent1.7.0 · 1×
typescript-eslint8.72.1 · 1×
xo5.0.1 · 1×
@eslint/markdown8.0.1 · 1×
@types/node26.6.6 · 1×
@typescript-eslint/parser8.72.1 · 1×
eslint10.14.0 · 1×
npm-run-all29.0.4 · 1×

For agents

$ 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 →

⬇ download graph artifact

Ask about this repo answers extend the page