Configs2026年5月25日·1 分钟阅读

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.

Agent 就绪

复制一段可直接交给 Agent 执行的安装路径

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
type-fest Overview
直接安装命令
npx -y tokrepo@latest install 4e847fd4-5857-11f1-9bc6-00163e2b0d79 --target codex

先 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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产