utility-types adds compile-time helpers such as DeepPartial, Brand, and set operators with no runtime dependencies or emitted JavaScript.
Overview
utility-types is an npm package that extends TypeScript with additional type-level utilities similar in spirit to lodash, but for static types. It complements built-in mapped types and aliases with operators for objects, unions, primitives, and Flow-inspired helpers.
Utilities cover set logic, deep partial and required transformations, picking and omitting by value, branded types, promise unwrapping, and guards such as `isPrimitive` or `isNullish`. Correctness is tested with dts-jest and the package stays free of runtime dependencies so bundlers emit no extra code.
Version lines track minimum TypeScript releases, with v3 targeting TypeScript 3.1 and above. Each operator is documented with examples, and contribution guidelines explain how to propose new types.
Teams import only the types they need for safer domain modeling, API contracts, and refactor-friendly generics without bolting on validation libraries.
Key features
- DeepPartial and DeepRequired helpers
- Set and union type operators
- Pick and omit by value matchers
- Branding and promise type helpers
- Primitive and nullish type guards
- Zero runtime bundle cost
- dts-jest type correctness tests
- Flow-inspired utility aliases
Use cases
- Partial type updates with DeepPartial
- Expressing branded ID types
- Refining unions with set operators
- Sharing reusable generic utilities
- Augmenting strict TypeScript codebases