Types Module (node-yalc/types)
The Types module provides advanced, globally available TypeScript utility types used extensively throughout the Ferrox-Node Framework to enforce extreme type safety and strict compiler checks.
Overview
TypeScript's standard library is powerful, but enterprise frameworks require more restrictive typing to prevent developer errors (like passing an object with extra, un-typed properties to a generic function).
Key Utilities Exported
Exact<T, U>: TypeScript is structurally typed, meaning an objectUcan have extra properties not defined inTand still be accepted.Exactenforces thatUhas only the properties defined inTand nothing more.CompareStrict<A, B>: Checks if typeAis exactly equal to typeB.NoExtraProperties<T, U>: Strips away any properties inUthat are not present in the base typeT.XOR<T, U>: Enforces an exclusive OR relationship between two types. A value must match exactlyTor exactlyU, but never a combination of both.Spread<L, R>: Strictly types the result of object spreading{ ...L, ...R }, correctly handling optional properties and overwriting.ClassType<T>: Represents a constructable class, heavily used in the Dependency Injection and Lifecycle hooks.DeepWritable<T>: Recursively removesreadonlymodifiers from all nested properties ofT.
Usage
These types are exported and can be used directly in your business logic.
import { Exact, XOR } from '@node-yalc/types';
// Enforce strict object shapes
function updateConfig<T>(config: Exact<ConfigSchema, T>) {
// config cannot contain properties not in ConfigSchema
}