Loading...
function make(...args: any[]) {
return new User(...args);
}function make(...args: ConstructorParameters<typeof User>) {
return new User(...args);
}The factory's arguments are now checked against the User constructor instead of accepting anything.
ConstructorParameters<User>, and getting a constraint error.typeof, as ConstructorParameters<typeof User>, not ConstructorParameters<User>....args: ConstructorParameters<typeof User>.Index the tuple: ConstructorParameters<typeof User>[0] is the type of the first argument.
Yes, its constraint accepts abstract constructor types, so ConstructorParameters<typeof Shape> works for an abstract Shape.