| name | mongez-reinforcements-types |
| description | TypeScript-only utility types from @mongez/reinforcements — Path/PathValue for dot-notation typing, DeepPartial/DeepRequired/DeepReadonly/DeepMutable transforms, Prettify, UnionToIntersection, Branded nominal types, and common aliases.
|
Types
TypeScript-only exports — zero runtime cost. Import as types:
import type {
Path, PathValue,
DeepPartial, DeepRequired, DeepReadonly, DeepMutable,
Prettify, UnionToIntersection, Branded,
Nullable, Maybe, Awaitable, NonEmptyArray,
GenericObject, AlphaNumeric, Primitive,
} from "@mongez/reinforcements";
Dot-notation paths
type Path<T, Depth = 6>
type PathValue<T, P extends string>
type User = {
id: number;
profile: { email: string; addresses: { city: string }[] };
};
type UserPath = Path<User>;
type Email = PathValue<User, "profile.email">;
type City = PathValue<User, "profile.addresses.0.city">;
Used internally to type get(obj, path) overloads.
Recursive transforms
type DeepPartial<T>
type DeepRequired<T>
type DeepReadonly<T>
type DeepMutable<T>
Each preserves primitives, Date, RegExp, Function, Map<K,V>, and Set<T> rather than recursing into them.
type Config = { api: { url: string; retries: number } };
type DraftConfig = DeepPartial<Config>;
type FrozenConfig = DeepReadonly<Config>;
Display & combinators
type Prettify<T>
type UnionToIntersection<U>
type Combined = Prettify<{ a: 1 } & { b: 2 }>;
Nominal types
type Branded<T, B extends string> = T & { readonly __brand: B }
Distinguish lookalike primitives at the type level.
type UserId = Branded<string, "UserId">;
type Email = Branded<string, "Email">;
declare function getUser(id: UserId): User;
const id = "abc" as UserId;
getUser(id);
getUser("abc");
Common aliases
type Nullable<T> = T | null
type Maybe<T> = T | null | undefined
type Awaitable<T> = T | Promise<T>
type NonEmptyArray<T> = [T, ...T[]]
type GenericObject<T=any> = Record<string, T>
type AlphaNumeric = string | number
type Primitive = AlphaNumeric | boolean
function init(input: Awaitable<Config>): Promise<void> { ... }
function first<T>(arr: NonEmptyArray<T>): T {
return arr[0];
}