Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 25, 2026·3 min de lecture

type-fest — Essential TypeScript Utility Types Collection

A curated collection of essential TypeScript types covering objects, strings, arrays, JSON, and more, maintained by Sindre Sorhus with strict typing guarantees.

Prêt pour agents

Copier un chemin d'installation prêt pour l'agent

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
type-fest Overview
Commande d'installation directe
npx -y tokrepo@latest install 4e847fd4-5857-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

type-fest provides a curated, well-tested collection of TypeScript utility types that fill gaps in the built-in utility types. Maintained by Sindre Sorhus, it covers deep partial, readonly, JSON types, string manipulation, and dozens more patterns commonly needed across TypeScript projects.

What type-fest Does

  • Provides deep recursive versions of built-in types like PartialDeep and ReadonlyDeep
  • Offers strict variants of Extract, Exclude, and Omit that catch typos at compile time
  • Includes JSON-related types for parsing and serialization safety (JsonValue, JsonObject)
  • Supplies string literal manipulation types like CamelCase, KebabCase, and Split
  • Adds array utilities like FixedLengthArray, ArraySlice, and LastArrayElement

Architecture Overview

type-fest is a pure type-level library with zero runtime code. Each type is defined in its own source file, tree-shakeable by design. The library requires TypeScript 5.9 or later and strict mode enabled. Types are organized by category and exported from a single entry point for convenient imports.

Self-Hosting & Configuration

  • Install via npm: npm install type-fest
  • Import types using import type syntax only (no runtime footprint)
  • Requires strict: true in tsconfig.json
  • Requires TypeScript 5.1 or later (5.9 recommended for latest features)
  • Works with any bundler or runtime since it emits no JavaScript

Key Features

  • Over 200 carefully designed utility types
  • Zero runtime overhead since every export is a pure type
  • Strict mode variants that enforce exact key matching
  • Extensive JSDoc documentation with inline examples for every type
  • Battle-tested across thousands of npm packages

Comparison with Similar Tools

  • ts-toolbelt — larger library with 300+ types; heavier, more complex API surface
  • utility-types — smaller collection focused on mapped and conditional types; less maintained
  • ts-essentials — overlapping scope with deep partial and readonly types; fewer string utilities
  • TypeScript built-in utilities — Partial, Pick, Omit, etc.; lacks deep variants and string types
  • simplytyped — lightweight alternative; discontinued

FAQ

Q: Does type-fest add any runtime code to my bundle? A: No. Every export is a TypeScript type, removed entirely during compilation.

Q: Which TypeScript version is required? A: TypeScript 5.1 or later with strict mode enabled. Some newer types require 5.9.

Q: Can I use individual types without importing the whole package? A: Yes. Use import type { CamelCase } from 'type-fest' and your bundler will include only the type reference, which compiles away.

Q: How is PartialDeep different from the built-in Partial? A: The built-in Partial only makes top-level properties optional. PartialDeep recursively makes every nested property optional as well.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires