quickmodel / IQImplements
Type Alias: IQImplements<TInterface, TTransforms>
IQImplements<
TInterface,TTransforms> =Omit<TInterface, keyofTTransforms> &TTransforms
Helper type for defining type transformations in models.
Allows you to specify which properties have different types in JSON (TInterface) versus in memory (after transformation). This is essential for types like Date, BigInt, RegExp, etc. that need serialization/deserialization.
Type Parameters
TInterface
TInterface
Base model interface representing JSON structure
TTransforms
TTransforms extends Partial<Record<keyof TInterface, unknown>> | IQAnyRecord = { }
Object mapping property names to their transformed types
See
- QModel — the base class that performs the actual type transformation at runtime
- Quick — decorator that maps each property to its transformer
- QModel — base class for models that
implementthis helper type - IQAnyRecord — escape-hatch type used in the
TTransformsconstraint
Examples
Basic usage with type transformations
interface IUser {
id: string;
balance: string; // In JSON: string
createdAt: string; // In JSON: ISO date string
}
type UserTransforms = {
balance: bigint; // In memory: bigint
createdAt: Date; // In memory: Date object
};
class User extends QModel<IUser, UserTransforms>
implements IQImplements<IUser, UserTransforms> {
declare id: string;
declare balance: bigint;
declare createdAt: Date;
}Multiple type transformations
interface IProduct {
id: string;
price: string; // JSON: string
regex: object; // JSON: IQSerialized regex
updated: string; // JSON: ISO string
}
type ProductTransforms = {
price: bigint;
regex: RegExp;
updated: Date;
};
class Product extends QModel<IProduct, ProductTransforms>
implements IQImplements<IProduct, ProductTransforms> {
declare id: string;
declare price: bigint;
declare regex: RegExp;
declare updated: Date;
}