Skip to content

uni-typesTypeScript Type Utilities

A comprehensive collection of 700+ type utilities for TypeScript development - enterprise patterns, real-time systems, and more

uni-types

Quick Example

typescript
import type {
  PickRequired, DeepPartial, Sort, IsArray,
  GraphQLQuery, WebSocketMessage, EventBus, Workflow,
  Tensor, Model, Maybe, Either, Infer
} from 'uni-types'

// Core: Make specific properties required
interface User {
  name?: string
  age?: number
  email: string
}
type RequiredUser = PickRequired<User, 'name' | 'age'>

// Deep partial for nested objects
interface Config {
  database: { host: string; port: number }
}
type PartialConfig = DeepPartial<Config>

// Type-level sorting algorithm
type Sorted = Sort<[3, 1, 4, 1, 5]> // [1, 1, 3, 4, 5]

// GraphQL query type (v1.5.0)
type GetUserQuery = GraphQLQuery<{ id: string }, { userId: string }>

// WebSocket message type (v1.5.0)
type ChatMessage = WebSocketMessage<{ text: string; userId: string }>

// Event bus type (v1.5.0)
type AppEvents = EventBus<{ userCreated: { id: string }; orderPlaced: { orderId: string } }>

// Workflow type (v1.5.0)
type OrderWorkflow = Workflow<{ orderId: string; status: string }>

// AI/ML tensor type (v1.6.0)
type ImageTensor = Tensor<[224, 224, 3], 'float32'>

// Functional programming (v1.6.0)
type OptionalValue = Maybe<string> // Some<string> | None
type Result = Either<Error, string> // Left<Error> | Right<string>

// Type inference (v1.6.0)
type PromiseValue = Infer<Promise<string>> // string

// Metaprogramming (v1.7.0)
type Analysis = AnalyzeType<{ nested: { deep: string } }>
type Visual = VisualizeType<{ a: number; b: string }>

// Decorator types (v1.7.0)
type LoggedMethod = MethodDecorator<(arg: string) => void>

// Type generation (v1.7.0)
type GeneratedUser = GenerateFromSchema<{ name: 'string'; age: 'number' }>

// Crypto types (v1.7.0)
type Sha256Hash = HashOutput<256>

// Date/Time types (v1.7.0)
type UserDuration = Duration<{ hours: number; minutes: number }>

// Type-level math (v1.7.0)
type Sum = Add<10, 20> // number
type IsSevenPrime = IsPrime<7> // true

// Type-level search (v1.7.0)
type UniqueNumbers = Unique<[1, 2, 2, 3, 3]> // [1, 2, 3]
type Intersect = Intersection<[1, 2, 3], [2, 3, 4]> // [2, 3]

Why uni-types?

Zero Dependencies

Lightweight with no external dependencies. Just pure TypeScript type magic.

TypeScript 5+

Built with the latest TypeScript features for the best type inference.

::: success Enterprise Ready 700+ types covering microservices, event-driven architecture, workflow engines, and real-time systems. :::

Released under the MIT License.