T
GenerateTypes
testedGenerates a type for a template string with placeholders.
Example
ts
type Base = GenerateTypes<'Hello {user.name}, your address {user.addresses.0.street}'>; // { user: { name: string; addresses: { 0: { street: string; }; }; }; }
type WithTarget = GenerateTypes<'Hello {user.age}', number>; // { user: { age: number; }; }Signature
ts
export type GenerateTypes<T extends string, Target = string>
// No placeholders (T is never) → impose no shape on the args object.
= [T] extends [never]
? Collection
: UnionToIntersection<PathToPartialType<Path<T>, Target>>;Type Parameters
Textends stringTarget= string