TypeScript's built-in utility types are great, but they don't go deep enough for real-world complex types. TypeForge-ts fills the gap with advanced type-level utilities that save hundreds of lines of boilerplate.
What is TypeForge-ts?
A zero-dependency TypeScript utility type library with deep transformations, path inference, conditional utilities, and more.
npm install typeforge-ts
bun add typeforge-ts
DeepPartial & DeepRequired
import type { DeepPartial, DeepRequired } from 'typeforge-ts';
type Config = {
server: { host: string; port: number };
db: { url: string; pool: { min: number; max: number } };
};
type PartialConfig = DeepPartial<Config>;
// Every nested field becomes optional recursively!
type FullConfig = DeepRequired<Config>;
// Every nested field becomes required!
Paths & PathValue
import type { Paths, PathValue } from 'typeforge-ts';
type User = { id: number; profile: { name: string; avatar: { url: string } } };
type UserPaths = Paths<User>;
// 'id' | 'profile' | 'profile.name' | 'profile.avatar.url'
type NameType = PathValue<User, 'profile.name'>; // string
function get<T, P extends Paths<T>>(obj: T, path: P): PathValue<T, P> {
// Type-safe nested getter!
}
Flatten
import type { Flatten } from 'typeforge-ts';
type Nested = { a: { b: { c: string } } };
type Flat = Flatten<Nested>; // { 'a.b.c': string }
Why TypeForge-ts?
- Zero dependencies
- Zero runtime cost (type-level only)
- Works with TypeScript 4.7+
- Tree-shakeable
GitHub: https://github.com/Avinashvelu03/TypeForge-ts
What TypeScript utility types do you write over and over? Let's discuss!
Top comments (0)