Socket
Socket
Sign inDemoInstall

type-fest

Package Overview
Dependencies
0
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    type-fest

A collection of essential TypeScript types


Version published
Maintainers
1
Install size
27.3 kB
Created

Package description

What is type-fest?

The type-fest package provides a collection of essential TypeScript types for use in a wide range of applications. It includes utility types, primitive types, and complex object types to enhance TypeScript's static typing capabilities.

What are type-fest's main functionalities?

Primitive types

Includes types like LiteralUnion, Primitive, and Promisable, which help with defining literals, primitive values, and promise-like structures.

{"isPrimitive": true}

Basic utilities

Provides utility types such as Except, Mutable, ReadonlyDeep, and many others that help manipulate and transform types in various ways.

{"isEmptyArray": array.length === 0}

Object types

Contains types for working with objects, such as Merge and RequireAtLeastOne, which assist in merging types and ensuring at least one property is present, respectively.

{"isObjectClean": Object.keys(object).length === 0 && object.constructor === Object}

Conditional types

Includes conditional types like ConditionalExcept and ConditionalKeys, which apply conditions to filter keys or properties of types.

{"isTruthy": T extends false | '' | 0 | null | undefined ? false : true}

Other packages similar to type-fest

Readme

Source


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

Requires TypeScript >=3.2

Usage

import {Omit} from 'type-fest';

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

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

API

Click the type names for complete docs.

Basic

Utilities

  • Omit - Create a type from an object type without certain keys.
  • Mutable - Convert an object with readonly properties into a mutable object. Inverse of Readonly<T>.
  • 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.
  • ReadonlyDeep - Create a deeply immutable version of a object/Map/Set/Array 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. Workaround for Microsoft/TypeScript#29729.

Miscellaneous

Declined types

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

  • Diff and Spread - The PR author didn't provide any real-world use-cases and the PR went stale. If you think this type is useful, provide some real-world use-cases and we might reconsider.

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)

Keywords

FAQs

Last updated on 26 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc