Skip to content
A collection of essential TypeScript types
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Upgrade `tsd` dev dependency Mar 20, 2019
media Init Mar 13, 2019
source Add `PackageJson` and `LiteralUnion` types (#5) Mar 15, 2019
test-d Add negative tests for RequireAtLeastOne (#13) Mar 21, 2019
.editorconfig Init Mar 13, 2019
.gitattributes Init Mar 13, 2019
.gitignore Init Mar 13, 2019
.npmrc Init Mar 13, 2019
.travis.yml Init Mar 13, 2019
index.d.ts Add a note about the TS issue on `Omit` (#11) Mar 20, 2019
license Init Mar 13, 2019
license-cc0 Init Mar 13, 2019
package.json Add `@sindresorhus/tsconfig` to devDependencies (#12) Mar 21, 2019
readme.md Welcome @BendingBender as a maintainer Mar 19, 2019
tsconfig.json Init Mar 13, 2019

readme.md



type-fest

A collection of essential TypeScript types



Build Status

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.

Install

$ npm install type-fest

Usage

import {Omit} from 'type-fest';

type Foo = {
	unicorn: string;
	rainbow: boolean;
};

type FooWithoutRainbow = Omit<Foo, 'rainbow'>;
//=> {unicorn: string}

API

See the types file for complete docs.

Basic

  • Primitive - Matches any primitive value.
  • Class - Matches a class constructor.
  • TypedArray - Matches any typed array, like Uint8Array or Float64Array.
  • JsonObject - Matches a JSON object.
  • JsonArray - Matches a JSON array.
  • JsonValue - Matches any valid JSON value.
  • ObservableLike - Matches a value that is like an Observable.

Utilities

  • Omit - Create a type from an object type without certain keys.
  • Merge - Merge two types into a new type. Keys of the second type overrides keys of the first type.
  • MergeExclusive - Create a type that has mutually exclusive properties.
  • RequireAtLeastOne - Create a type that requires at least one of the given properties.
  • LiteralUnion - Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union. Workaround for Microsoft/TypeScript#29729.

Miscellaneous

Declined types

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

Tips

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

(MIT OR CC0-1.0)

You can’t perform that action at this time.