API Reference
Complete API reference for all type utilities in uni-types.
Categories
Core Operations
| Type | Description |
|---|---|
PickRequired<T, K> | Make specified properties required |
PickPartial<T, K> | Make specified properties optional |
OmitRequired<T, K> | Make properties required except specified |
OmitPartial<T, K> | Make properties optional except specified |
Tuple Operations
| Type | Description |
|---|---|
Head<T> | Get first element of tuple |
Last<T> | Get last element of tuple |
Tail<T> | Get all elements except first |
Init<T> | Get all elements except last |
Reverse<T> | Reverse a tuple |
Flatten<T> | Flatten nested tuples |
TupleLength<T> | Get tuple length |
IsEmptyTuple<T> | Check if tuple is empty |
Deep Operations
| Type | Description |
|---|---|
DeepPartial<T> | Make all nested properties optional |
DeepRequired<T> | Make all nested properties required |
DeepReadonly<T> | Make all nested properties readonly |
DeepMutable<T> | Make all nested properties mutable |
DeepOmit<T, P> | Omit properties at nested paths |
DeepPick<T, P> | Pick properties at nested paths |
Brand Types
| Type | Description |
|---|---|
Brand<T, B> | Create a branded nominal type |
Unbrand<T> | Extract underlying type from branded type |
Conditional Types
| Type | Description |
|---|---|
If<C, T, F> | If-then-else at type level |
Not<B> | Logical NOT for boolean types |
And<A, B> | Logical AND for boolean types |
Or<A, B> | Logical OR for boolean types |
Function Types
| Type | Description |
|---|---|
Parameters<T> | Get function parameters as tuple |
ReturnType<T> | Get function return type |
NthParameter<T, N> | Get Nth parameter type |
AsyncReturnType<T> | Unwrap Promise return type |
Key Utilities
| Type | Description |
|---|---|
RenameKeys<T, M> | Rename object keys |
PrefixKeys<T, P> | Add prefix to all keys |
SuffixKeys<T, S> | Add suffix to all keys |
KeysByValueType<T, V> | Get keys by value type |
Numeric Types
| Type | Description |
|---|---|
Inc<N> | Increment number type |
Dec<N> | Decrement number type |
Add<A, B> | Add two number types |
Subtract<A, B> | Subtract two number types |
Range<From, To> | Create number range union |
Path Utilities
| Type | Description |
|---|---|
ValidPath<T, P> | Check if path exists in type |
ArrayPaths<T> | Get all paths with array indices |
LeafPaths<T> | Get paths to leaf nodes |
PathLength<P> | Get path segment count |
Record Types
| Type | Description |
|---|---|
DeepNullable<T> | Make all properties nullable |
DeepOptional<T> | Make all properties optional |
Immutable<T> | Make all properties readonly |
Mutable<T> | Remove readonly from all properties |
Template Literals
| Type | Description |
|---|---|
ReplaceAll<S, From, To> | Replace all occurrences |
Trim<S> | Trim whitespace |
StringLength<S> | Get string length |
Repeat<S, N> | Repeat string N times |
Type Guards
| Type | Description |
|---|---|
IsArray<T> | Check if type is array |
IsTuple<T> | Check if type is tuple |
IsEqual<X, Y> | Check if types are equal |
IsAny<T> | Check if type is any |
IsNever<T> | Check if type is never |
IsUnknown<T> | Check if type is unknown |
Type Inference
| Type | Description |
|---|---|
Awaited<T> | Unwrap Promise type |
ArrayElement<T> | Get array element type |
ValueOf<T> | Get object value types |
FunctionKeys<T> | Get function property keys |
NonFunctionKeys<T> | Get non-function property keys |
FirstParameter<T> | Get first parameter type |
FunctionOnly<T> | Extract function properties |
DataOnly<T> | Extract non-function properties |
Utility Types
| Type | Description |
|---|---|
Merge<T, U> | Merge two types |
NonNullable<T> | Exclude null/undefined |
Exclusive<T, K> | Create exclusive properties |
NoNullish<T> | Remove null/undefined from all properties |
Nullable<T> | Add null to type |
Optional<T> | Add undefined to type |
Maybe<T> | Add null/undefined to type |
LoosePartial<T> | Make all properties optional |
Key Types
| Type | Description |
|---|---|
RequiredKeys<T> | Get required property keys |
OptionalKeys<T> | Get optional property keys |
WritableKeys<T> | Get writable property keys |
ReadonlyKeys<T> | Get readonly property keys |
Path Types
| Type | Description |
|---|---|
Paths<T> | Get all nested property paths |
PathValue<T, P> | Get value type at path |
SplitPath<S> | Split path into array |
String Case
| Type | Description |
|---|---|
CamelCase<S> | Convert to camelCase |
SnakeCase<S> | Convert to snake_case |
CamelCaseKeys<T> | Convert object keys to camelCase |
SnakeCaseKeys<T> | Convert object keys to snake_case |
Advanced Types
| Type | Description |
|---|---|
AtLeastOne<T> | Require at least one property |
StrictExtract<T, U> | Strictly extract types |
StrictExclude<T, U> | Strictly exclude types |
UnionToIntersection<U> | Union to intersection |
UnionToTuple<T> | Union to tuple |
Algorithms
| Type | Description |
|---|---|
Sort<T, Order> | Sort tuple of numbers |
QuickSort<T> | QuickSort implementation |
MergeSort<T> | MergeSort implementation |
GCD<A, B> | Greatest Common Divisor |
LCM<A, B> | Least Common Multiple |
Factorial<N> | Factorial of number |
Fibonacci<N> | Fibonacci number |
IsPrime<N> | Check if number is prime |
Find<T, P> | Find first element matching predicate |
FindIndex<T, P> | Find index of first match |
Includes<T, U> | Check if tuple includes element |
IndexOf<T, U> | Get index of element |
LongestCommonPrefix<T> | Find longest common prefix |
Reverse<T> | Reverse a tuple |
Unique<T> | Remove duplicates from tuple |
Flatten<T> | Flatten nested tuples |
FlattenDeep<T> | Deep flatten nested tuples |
LevenshteinDistance<A, B> | Levenshtein distance between strings |
Parsers
| Type | Description |
|---|---|
ParseJSON<S> | Parse JSON string to type |
StringifyJSON<T> | Stringify type to JSON |
IsValidJSON<S> | Check if valid JSON |
ParseURL<S> | Parse URL string |
QueryParams<S> | Parse query string |
ParseCSV<S> | Parse CSV string |
State Machines
| Type | Description |
|---|---|
StateMachine<T> | State machine definition |
State<S, Data> | State definition |
Transition<E, From, To> | Transition definition |
Data Structures
| Type | Description |
|---|---|
Tree<T> | Tree type |
TreeNode<T> | Tree node type |
Graph<A> | Graph type (adjacency list) |
LinkedList<T> | Linked list type |
Stack<T> | Stack type (LIFO) |
Queue<T> | Queue type (FIFO) |
HTTP & API
| Type | Description |
|---|---|
HTTPMethod | HTTP methods union |
HTTPStatus | HTTP status codes |
Route<P, M, H> | Route definition |
Middleware<C> | Middleware function |
Database
| Type | Description |
|---|---|
SQLType<T> | TS to SQL type mapping |
QueryBuilder<T> | Query builder |
Migration<T> | Migration definition |
Concurrency
| Type | Description |
|---|---|
Task<T> | Task type |
Pipeline<I, O> | Pipeline type |
Scheduler<T> | Scheduler type |
WorkerPool<I, O> | Worker pool type |
Interop
| Type | Description |
|---|---|
ToTypeFest<T> | Convert to type-fest |
ToTsToolbelt<T> | Convert to ts-toolbelt |
IsCompatible<T, U> | Check type compatibility |
Testing
| Type | Description |
|---|---|
ExpectTrue<T> | Expect type to be true |
ExpectEqual<T, U> | Expect types equal |
TypeCoverage<T> | Type coverage analysis |
TypeComplexity<T> | Type complexity analysis |
Assert
| Type | Description |
|---|---|
AssertEqual<T, Expected> | Assert types are equal |
AssertExtends<T, U> | Assert T extends U |
AssertKeyof<T, K> | Assert K is a key of T |
AssertNotNil<T> | Assert type is not never |
RequireKeys<T, K> | Require specific keys |
MakeOptional<T, K> | Make specific keys optional |
RequireAtLeastOne<T, K> | Require at least one key |
RequireExactlyOne<T, K> | Require exactly one key |
AssertHasProperty<T, K> | Ensure object has property |
RequireNotNullish<T> | Ensure type is not nullish |
RequireArray<T> | Ensure type is an array |
RequireFunction<T> | Ensure type is a function |
Async
| Type | Description |
|---|---|
PromiseValue<T> | Extract Promise value recursively |
PromiseResult<T> | Get Promise resolved value |
IsPromise<T> | Check if type is Promise |
UnwrapPromise<T> | Unwrap Promise to value |
WrapPromise<T> | Wrap type in Promise |
PromiseSettledResult<T> | Promise settlement result |
Collection
| Type | Description |
|---|---|
TypeSet<T> | Type-level set |
SetAdd<S, T> | Add element to set |
SetRemove<S, T> | Remove element from set |
SetHas<S, T> | Check if element in set |
SetUnion<A, B> | Union of sets |
SetIntersection<A, B> | Intersection of sets |
SetDifference<A, B> | Difference of sets |
SetIsEmpty<S> | Check if set is empty |
SetIsSubset<A, B> | Check if A is subset of B |
TypeMap<K, V> | Type-level map |
MapGet<M, K> | Get value from map |
MapSet<M, K, V> | Set value in map |
MapHas<M, K> | Check if key in map |
MapDelete<M, K> | Delete key from map |
MapKeys<M> | Get map keys |
MapValues<M> | Get map values |
ListLength<T> | Get list length |
ListReverse<T> | Reverse list |
ListConcat<A, B> | Concatenate lists |
ListFilter<T, P> | Filter list elements |
ListFind<T, P> | Find element in list |
ListIncludes<T, U> | Check if list includes |
Object
| Type | Description |
|---|---|
ObjectMap<T, F> | Map over object values |
ObjectFilter<T, P> | Filter object properties |
ObjectPickByType<T, U> | Pick by value type |
ObjectOmitByType<T, U> | Omit by value type |
ObjectInvert<T> | Invert keys and values |
DeepMerge<T, U> | Deep merge objects |
DeepAssign<T, U> | Deep assign properties |
DeepDefaults<T, U> | Deep defaults |
HasProperty<T, K> | Check if has property |
HasProperties<T, K> | Check if has properties |
HasMethod<T, K> | Check if has method |
Pattern
| Type | Description |
|---|---|
Match<T, Patterns> | Pattern matching |
Case<P> | Case helper for matching |
Default<R> | Default case |
TypeFilter<T, P> | Filter tuple by predicate |
TypeFind<T, P> | Find element by predicate |
TypeIncludes<T, P> | Check if type in tuple |
String
| Type | Description |
|---|---|
Split<S, D> | Split string by delimiter |
Join<T, S> | Join strings with separator |
KebabCase<S> | Convert to kebab-case |
PascalCase<S> | Convert to PascalCase |
IsEmail<T> | Check if email format |
IsUUID<T> | Check if UUID format |
IsURL<T> | Check if URL format |
Chunk<S, N> | Chunk string into parts |
Performance
| Type | Description |
|---|---|
Simplify<T> | Simplify complex types |
DeepSimplify<T> | Deep simplify types |
Cached<T> | Cache type computation |
CachedValue<T> | Extract cached value |
Memoized<T> | Memoize type |
Lazy<T> | Lazy type wrapper |
ForceEvaluate<T> | Force evaluate lazy type |
Deferred<T> | Defer type expansion |
FlattenType<T> | Flatten intersections |
StripNever<T> | Strip never properties |
StripUndefined<T> | Strip undefined properties |
Compact<T> | Remove never and undefined |
Schema
| Type | Description |
|---|---|
RuntimeGuard<T> | Runtime type guard |
GuardedType<G> | Extract guarded type |
HasRuntimeCheck<T> | Check if has runtime check |
CompositeGuard<T> | Composite object guard |
ZodOutput<T> | Extract Zod output type |
ZodInput<T> | Extract Zod input type |
IsZodSchema<T> | Check if Zod schema |
ZodShape<T> | Extract Zod shape |
ZodArrayElement<T> | Get Zod array element |
YupOutput<T> | Extract Yup output type |
YupInput<T> | Extract Yup input type |
IsYupSchema<T> | Check if Yup schema |