The transformer class to infer variant data from
Maximum depth allowed for unpacking (defaults to -1 for unlimited)
Current depth level (defaults to 0)
class UserTransformer extends BaseTransformer<User> {
toObject() { return { id: 1, name: "John" } }
toSummary() { return { id: 1 } }
toProfile() { return { id: 1, name: "John", email: "john@example.com" } }
}
type UserVariants = InferVariants<UserTransformer>
// Result: {
// toSummary: { id: number }
// toProfile: { id: number; name: string; email: string }
// }
Infers the data structure for all variant methods of a transformer class, excluding the default 'toObject' method and base transformer methods.
Use this type to extract types for all custom variant methods defined on a transformer.