A comprehensive collection of type-safe utility types for TypeScript.
Provides missing TypeScript utility types that should exist in the standard library but don't:
- Deep types — Recursive transformations on nested objects
- String types — Case conversion (camelCase, snake_case, kebab-case)
- Function types — Parameter/return type extraction
- Type guards — Runtime type checking
- Object utilities — Key/value manipulation
# npm
npm install ts-deep-types
# pnpm
pnpm add ts-deep-types
# yarn
yarn add ts-deep-typesimport { DeepPartial, CamelCase, Parameters, IsAny } from 'ts-deep-types'
// Deep types
type PartialConfig = DeepPartial<{
database: { host: string; port: number }
}>
// { database?: { host?: string; port?: number } | undefined }
// String types
type CamelStr = CamelCase<'hello_world'>
// 'helloWorld'
// Function types
type FnParams = Parameters<(a: string, b: number) => void>
// [string, number]
// Type guards
type TestAny = IsAny<any> // true
type TestNever = IsAny<never> // falseDeepPartial- Recursive partial typesDeepRequired- Recursive required typesDeepReadonly- Deep readonly for nested objectsPickDeep- Deep pick with nested pathsOmitDeep- Deep omit with nested pathsMerge- Merge two object typesUnionToIntersection- Convert union to intersection
CamelCase- Convert to camelCaseKebabCase- Convert to kebab-caseSnakeCase- Convert to snake_casePascalCase- Convert to PascalCaseTrim- Trim strings in templates
Parameters- Function parametersReturnType- Return typeThisParameterType-thisparameter typeAsyncReturnType- Async version of ReturnType
IsAny- Check if type isanyIsNever- Check if type isneverIsUnknown- Check if type isunknownIsUnion- Check if type is a unionIsTuple- Check if type is a tupleIsArray- Check if type is an arrayIsPlainObject- Check if type is a plain objectIsFunction- Check if type is a functionIsConstructor- Check if type is a constructor
KeysOfType- Keys matching a typeValueOf- Values of a union typeEntryOf- Key-value entriesRequiredKeys- Keys that are requiredOptionalKeys- Keys that are optionalReadonlyKeys- Keys that are readonlyWritableKeys- Keys that are mutable
TypeScript's standard utility types (Partial, Pick, Omit) only work at one level. When you need recursive transformations, you're on your own.
ts-deep-types provides the missing utilities:
// Standard library (one level)
type A = Partial<{ a: { b: { c: string } } }>
// { a?: { b?: { c?: string } } | undefined } | undefined
// ts-deep-types (recursive)
type B = DeepPartial<{ a: { b: { c: string } } }>
// { a?: { b?: { c?: string } } | undefined } | undefined }
// All levels are partial!# Install dependencies
pnpm install
# Run tests
pnpm test
# Build for production
pnpm buildMIT © Peter W.
Issues and PRs welcome!