type-fest README

The project's README from github.com/sindresorhus/type-fest. As one markdown file: README.md.



type-fest

A collection of essential TypeScript types




Sindre Sorhus' open source work is supported by the community

Special thanks to:

nitric logo
Effortless backends with infrastructure from code
An open-source framework that supports any programming language, cloud provider, or deployment automation tool.





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

Type Guard

type-fest (sindresorhus/type-fest)

Searching Database…

17.5K ·GitHub
What is this?type-fest is a collection of essential TypeScript types — helper types the author feels should have been built into the language, covering objects, unions, strings, arrays, tuples and functions.
Is it a runtime library or just type definitions?Just types — definitions your compiler consumes at build time; nothing executes in your app. For runtime functions the author publishes a separate companion package, ts-extras.
How do I add it to a project?Install it as a dependency with npm install type-fest and import the types you need — or skip the package entirely and copy-paste just the definitions you want.
Does my project need a specific TypeScript setup?Yes — TypeScript 5.9 or newer, ESM, and strict mode ({strict: true}) in tsconfig; older or non-strict codebases will not accept it. Also, the GitHub README documents the unreleased dev version, so released docs live on npm.
What kinds of types does it include?Well over a hundred, in three groups: Basic (Primitive, Class, TypedArray), Utilities (Except, Merge, LiteralUnion, PartialDeep, Get...) and Type Guards (If, IsLiteral, IsNumericLiteral).
Which types are worth knowing first?Except removes keys from an object type, Merge combines two types, LiteralUnion keeps IDE autocomplete for literal unions, and Get fetches a nested property like Lodash's .get().
Do I have to credit the author if I copy-paste types into my code?No — type-fest is licensed CC0-1.0, effectively public domain, and the README says copy-pasting the needed types requires no credit.
Does it keep up with new TypeScript releases?Likely yes: the repo's CI includes a canary workflow that tests unreleased TypeScript builds, and the README encourages suggesting types that belong in the language to the TypeScript project itself.
Size
4.2 MB
Stars
17.5K
Age
7y
Commits · 90 Days