MCPcopy
hub / github.com/sindresorhus/type-fest

github.com/sindresorhus/type-fest @v5.7.0 sqlite

repository ↗ · DeepWiki ↗ · release v5.7.0 ↗
188 symbols 500 edges 436 files 3 documented · 2%
README
<img src="https://github.com/sindresorhus/type-fest/raw/v5.7.0/media/logo.svg" alt="type-fest" height="300">






<b>A collection of essential TypeScript types</b>












<hr>









            <sup>
                <a href="https://github.com/sponsors/sindresorhus">Sindre Sorhus' open source work is supported by the community</a>
            </sup>



        <sup>Special thanks to:</sup>






        <a href="https://nitric.io/?utm_campaign=github_repo&utm_medium=referral&utm_content=sindresorhus&utm_source=github">



                <img width="230" src="https://sindresorhus.com/assets/thanks/nitric-logo.svg" alt="nitric logo">



            <b>Effortless backends with infrastructure from code</b>



                <sup>An open-source framework that supports any programming language, cloud provider, or deployment automation tool.</sup>



        </a>






        <a href="https://circleback.ai?utm_source=sindresorhus&utm_medium=sponsorship&utm_campaign=awesome-list&utm_id=type-fest">



                <img width="300" src="https://sindresorhus.com/assets/thanks/circleback-logo.png?x" alt="Circleback logo">



            <b>Get the most out of every conversation.</b>



                <sup>AI-powered meeting notes, automations, and search. Give AI agents the context they need to get things done.</sup>



        </a>









<hr>

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 >=5.9, ESM, and {strict: true} in your tsconfig.

[!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}

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.
  • 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 overrides keys of the first type.
  • 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.
  • OverrideProperties - Override existing properties of the given type. Similar to Merge, but enforces that the original type has the properties you want to override.
  • 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.
  • SingleKeyObject - Create a type that only accepts an object with a single key.
  • RequiredDeep - Create a deeply required version of another type.
  • 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.
  • PartialDeep - Create a deeply optional version of another type.
  • PartialOnUndefinedDeep - Create a deep version of another type where all keys accepting undefined type are set to optional.
  • UndefinedOnPartialDeep - Create a deep version of another type where all optional keys are set to also accept undefined.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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 null and undefined), supports deeply nested key paths, and leaves all other keys unchanged.
  • NonNullableDeep - Recursively removes null and undefined from the specified type.
  • ValueOf - Create a union of the given object's values, and optionally specify which keys to get the values from.
  • ConditionalKeys - Extract the keys from a type where the value type of the key extends the given Condition.
  • ConditionalPick - Pick keys from the shape that matches the given Condition.
  • ConditionalPickDeep - Pick keys recursively from the shape that matches the given condition.
  • ConditionalExcept - Exclude keys from a shape that matches the given Condition.
  • UnionToIntersection - Convert a union type to an intersection type.
  • LiteralToPrimitive - Given a literal type return the primitive type it belongs to, or never if it's not a primitive.
  • LiteralToPrimitiveDeep - Like LiteralToPrimitive except it converts literal types inside an object or array deeply.
  • Stringified - Create a type with the keys of the given type changed to string type.
  • IterableElement - Get the element type of an Iterable/AsyncIterable. For example, Array, Set, Map, generator, stream, etc.
  • Entry - Create a type that describes a single key-value pair produced when calling a collection’s entries method.
  • Entries - Create a type that describes the key-value pairs produced when calling a collection’s entries method.
  • SetReturnType - Create a function type with a return type of your choice and the same parameters as the given function type.
  • SetParameterType - Create a function that replaces some parameters with the given parameters.
  • Simplify - Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
  • SimplifyDeep - Deeply simplifies an object type.
  • Get - Get a deeply-nested property from an object using a key path, like Lodash's .get() function.
  • KeyAsString - Get keys of the given type as strings.
  • Schema - Create a deep version of another object type where property values are recursively replaced into a given value type.
  • Exact - Create a type that does not allow extra properties, meaning it only allows properties that are explicitly declared.
  • KeysOfUnion - Create a union of all keys from a given type, even those exclusive to specific union members.
  • OptionalKeysOf - Extract all optional keys from the given type.
  • HasOptionalKeys - Returns a boolean for whether the given type has any optional fields.
  • RequiredKeysOf - Extract all required keys from

Extension points exported contracts — how you extend this code

FooInterface (Interface)
(no doc)
test-d/merge.ts
InterfaceType (Interface)
(no doc)
test-d/paths.ts
MovablePosition (Interface)
(no doc)
test-d/conditional-simplify-deep.ts
BarBaz (Interface)
(no doc)
test-d/simplify-deep.ts
SomeInterface (Interface)
(no doc)
test-d/simplify.ts
A (Interface)
(no doc)
test-d/jsonify.ts
InterfaceA (Interface)
(no doc)
test-d/conditional-pick-deep.ts
DeepInterface (Interface)
(no doc)
test-d/pick-deep.ts

Core symbols most depended-on inside this repo

jsdoc
called by 66
lint-rules/test-utils.js
fence
called by 62
lint-rules/test-utils.js
exportTypeAndOption
called by 61
lint-rules/test-utils.js
function_
called by 58
test-d/exact.ts
errorAt
called by 53
lint-rules/test-utils.js
createComplexOption
called by 23
test-d/schema.ts
fixturePath
called by 10
lint-rules/test-utils.js
run
called by 7
test-d/conditional-pick.ts

Shape

Function 91
Class 63
Interface 18
Method 15
Enum 1

Languages

TypeScript100%

Modules by API surface

test-d/jsonify.ts21 symbols
test-d/class.ts17 symbols
test-d/abstract-class.ts17 symbols
lint-rules/validate-jsdoc-codeblocks.js14 symbols
lint-rules/test-utils.js11 symbols
test-d/structured-cloneable.ts4 symbols
test-d/merge-deep.ts4 symbols
test-d/find-global-type.ts4 symbols
lint-rules/require-export.js4 symbols
test-d/set-parameter-type.ts3 symbols
test-d/require-one-or-none.ts3 symbols
test-d/require-exactly-one.ts3 symbols

Dependencies from manifests, versioned

@eslint/markdown8.0.1 · 1×
@sindresorhus/tsconfig8.0.1 · 1×
@types/node25.5.0 · 1×
@typescript-eslint/parser8.44.0 · 1×
@typescript/vfs1.6.1 · 1×
dedent1.7.0 · 1×
eslint10.1.0 · 1×
expect-type1.2.2 · 1×
npm-run-all28.0.4 · 1×
tagged-tag1.0.0 · 1×
tsd0.33.0 · 1×
typescript5.9.2 · 1×

For agents

$ claude mcp add type-fest \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact