Dependent Types API Reference
Core Dependent Types
Dep<T, P>
Simulated dependent type — constrains T to extend P.
import type { Dep } from 'uni-types'
type A = Dep<string, string> // string
type B = Dep<number, string> // neverDepValue<T, V extends T>
Value-dependent type — creates a type representing a specific value.
import type { DepValue } from 'uni-types'
type Hello = DepValue<string, 'hello'> // 'hello'DepIndex<T extends readonly unknown[], I extends keyof T>
Index-dependent type — extracts type by index.
import type { DepIndex } from 'uni-types'
type First = DepIndex<['a', 'b'], 0> // 'a'DepKey<T extends Record<string, unknown>, K extends keyof T>
Key-dependent type — extracts type by key.
import type { DepKey } from 'uni-types'
type Name = DepKey<{ name: string; age: number }, 'name'> // stringValue-Dependent Types
ValueOf<T, V>
Filters types matching a specific value.
import type { ValueOf } from 'uni-types'
type R = ValueOf<string, string> // stringWhere<T, Condition>
Conditional type constraint — filters by condition.
import type { Where } from 'uni-types'
type R = Where<string, string> // stringSuchThat<T, Predicate>
Predicate-based type narrowing.
import type { SuchThat } from 'uni-types'
type R = SuchThat<string, string> // stringConstraint Verification
Satisfies<T, Constraint>
Verifies that a type satisfies a constraint without widening.
import type { Satisfies } from 'uni-types'
type R = Satisfies<{ a: number }, { a: number }> // { a: number }Exactly<T, Shape>
Ensures a type exactly matches another, with no excess properties.
import type { Exactly } from 'uni-types'
type R = Exactly<{ a: number }, { a: number }> // { a: number }Proof-Carrying Types
Proof<T, P extends string>
Type-level proof carrier.
import type { Proof } from 'uni-types'
type P = Proof<string, 'non-empty'>
// P._value: string, P._proof: 'non-empty'Prove<T, Constraint extends string>
Creates a proof that a type satisfies a constraint.
Verified<T>
A type verified to satisfy constraints. Adds __verified__: true and __verifiedAt__: number.
Unverified<T>
Removes verification from a verified type.
Refinement Types
Refined<T, Predicate>
Refine<T, R extends string>
Unrefine<T>
Type-Level Equality
TypeEq<A, B>
Strict type equality check returning true or false.
TypeNotEq<A, B>
TypeExtends<A, B>
TypeCompatible<A, B>
Returns true, 'partial', or false. Mutual extension returns true, one-way returns 'partial', neither returns false.
Type-Level Computation
DepCompute<T>
Interface with _result: T and _success: boolean.