{"id":12213,"library":"type-fest","title":"Type-Fest","description":"Type-Fest is a comprehensive collection of essential TypeScript utility types designed to simplify complex type manipulations and enhance type safety in modern TypeScript projects. Currently stable at version 5.6.0, the library maintains an active release cadence, frequently introducing new types and improving existing ones with minor and patch updates. It serves as a valuable resource for developers seeking robust, well-tested types that address common TypeScript patterns, often providing functionalities that many believe should be part of TypeScript's standard library. Key differentiators include its focus on practical, real-world utility types, its explicit requirement for TypeScript >=5.9 and ESM (ECMAScript Modules) environments, and the recommendation to enable `strict: true` in `tsconfig.json` for optimal usage. The library is also noteworthy for allowing developers to copy and paste types directly into their projects without attribution, promoting broad adoption.","status":"active","version":"5.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/type-fest","tags":["javascript","typescript","ts","types","utility","util","utilities","omit","merge"],"install":[{"cmd":"npm install type-fest","lang":"bash","label":"npm"},{"cmd":"yarn add type-fest","lang":"bash","label":"yarn"},{"cmd":"pnpm add type-fest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Always use 'import type' for type-only imports to prevent accidental runtime imports and ensure compatibility with ESM-only modules.","wrong":"import {Except} from 'type-fest';","symbol":"Except","correct":"import type {Except} from 'type-fest';"},{"note":"Type-Fest is an ESM-only package since v5. Using CommonJS 'require()' will result in a runtime error. Ensure 'import type' is used for type-only imports.","wrong":"const {Merge} = require('type-fest');","symbol":"Merge","correct":"import type {Merge} from 'type-fest';"},{"note":"While individual types are often organized into files, the recommended and stable import path is directly from the main 'type-fest' package. Ensure to use 'import type'.","wrong":"import {PackageJson} from 'type-fest/source/package-json';","symbol":"PackageJson","correct":"import type {PackageJson} from 'type-fest';"}],"quickstart":{"code":"import type {Except, Merge, Simplify} from 'type-fest';\n\ninterface User {\n  id: string;\n  name: string;\n  email: string;\n  createdAt: Date;\n  updatedAt?: Date;\n}\n\ninterface UserProfile {\n  bio: string;\n  website?: string;\n}\n\n// Create a new user type that excludes 'id' and 'createdAt'\ntype NewUser = Except<User, 'id' | 'createdAt'>;\n\n// Merge the new user type with a profile to create a complete user\ntype FullUser = Simplify<Merge<NewUser, UserProfile>>;\n\nconst newUser: FullUser = {\n  name: 'Alice Wonderland',\n  email: 'alice@example.com',\n  bio: 'Exploring type safety in Wonderland.',\n  website: 'https://alice.example.com'\n};\n\nconsole.log(newUser);\n\n// Demonstrating a common pattern with strict mode\n// Type-fest types are designed with strict mode in mind.\n// For example, if 'updatedAt' was not optional and not provided, \n// TypeScript would catch the missing property if strict: true is enabled.\nconst partialUserUpdate: Partial<NewUser> = { name: 'Alice Smith' };\nconsole.log(partialUserUpdate);","lang":"typescript","description":"Demonstrates the usage of 'Except', 'Merge', and 'Simplify' types to create new, refined types from existing interfaces, showcasing type composition."},"warnings":[{"fix":"Convert your project to use ECMAScript Modules (ESM) and use `import type { ... } from 'type-fest';`. If unable to convert, you may need to stick to an older major version (e.g., `type-fest@4`).","message":"Type-Fest versions 4.x and earlier supported CommonJS (CJS) modules. Starting with version 5.0.0, the library is exclusively ESM-first and no longer provides CJS exports. Attempting to `require()` Type-Fest will result in a runtime error.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Upgrade your TypeScript compiler to version 5.9 or newer. Ensure your `package.json` and project configuration (e.g., `engines.node`) reflect this requirement.","message":"Type-Fest requires TypeScript version 5.9 or higher. Using an older TypeScript version will lead to compilation errors due to reliance on newer TypeScript features and syntax.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Ensure your `tsconfig.json` has `\"strict\": true` under `\"compilerOptions\"`. This is a recommended best practice for all modern TypeScript projects.","message":"Many Type-Fest types are designed to work optimally and correctly infer types only when `strict: true` is enabled in your `tsconfig.json`. Without strict mode, some types may behave unexpectedly or provide less precise results.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Always prefix type imports with `type` (e.g., `import type { Except } from 'type-fest';`).","message":"When importing types from `type-fest`, always use the `import type` syntax (`import type { TypeName } from 'type-fest';`). While not strictly an error in all cases, using `import { TypeName } from 'type-fest';` (without `type`) can sometimes lead to runtime import errors in certain build environments or with specific bundlers, as `type-fest` only exports types, not runnable JavaScript values.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your project is configured for ESM and use `import type { Except } from 'type-fest';`. If using `require()`, switch to ESM `import` statements or use `type-fest@4` or earlier.","cause":"Attempting to import `type-fest` types in a CommonJS environment, or using an incorrect import syntax for ESM.","error":"SyntaxError: Named export 'Except' not found. The requested module 'type-fest' does not provide an export named 'Except'"},{"fix":"Add `\"strict\": true` to your `compilerOptions` in `tsconfig.json`. Review and fix any new type errors that appear, as they usually indicate genuine potential runtime issues.","cause":"Your `tsconfig.json` does not have `\"strict\": true` enabled, leading to less precise type inference, especially when working with optional properties or null/undefined values, which `type-fest` often helps manage in a strict way.","error":"Type 'string | undefined' is not assignable to type 'string'."},{"fix":"Ensure `npm install type-fest` has been run. Verify your TypeScript version is `>=5.9`. Check your `tsconfig.json`'s `moduleResolution` and `module` settings are compatible with ESM and modern TypeScript best practices.","cause":"TypeScript version is too old, the package is not installed correctly, or module resolution issues.","error":"error TS2307: Cannot find module 'type-fest' or its corresponding type declarations."}],"ecosystem":"npm"}