The Principal Dev – Masterclass for Tech Leads

The Principal Dev – Masterclass for Tech LeadsJuly 17-18

Join


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

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

JSON

Structured clone

Async

String

Array

Numeric

Change case

Miscellaneous

Improved built-in

Declined types

If we decline a type addition, we will make sure to document the better solution here.

Alternative type names

If you know one of our types by a different name, add it here for discovery.

Tips

Extending existing types

Built-in types

There are many advanced types most users don't know about.

You can find some examples in the TypeScript docs.

Maintainers

License

SPDX-License-Identifier: (MIT OR CC0-1.0)

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.