The transformer class to infer data from
The variant method name to use (defaults to 'toObject')
Maximum depth allowed for unpacking (defaults to -1 for unlimited)
Current depth level (defaults to 0)
class UserTransformer extends BaseTransformer<User> {
toObject() {
return {
id: this.resource.id,
name: this.resource.name,
posts: PostTransformer.transform(this.resource.posts)
}
}
}
type UserData = InferData<UserTransformer>
// Result: { id: number; name: string; posts: PostData[] }
Infers the serialized data structure of a transformer by extracting the return type of a specific variant method and unpacking it recursively.
This is the primary type used to extract the TypeScript type of a transformer's output.