I wonder if there is any way of mapping ConstructorParameters<T> to an object where each key is the parameter name and the key is the type of the parameter.
What I mean is, given:
class User {
public id: number;
constructor(
public readonly name: string,
public readonly surname: string,
) {}
get fullname(): string { ... }
public isAdmin(): boolean { ... }
}
With ConstructorParameters<typeof User> I get the type [name: string, surname: string]. Maybe this can be mapped to the following type { name: string, surname: string }? Note that the type should omit: id, fullname & isAdmin as they are not present on the constructor.
I've seen https://stackoverflow.com/a/49062616 which is a really cool solution but it breaks with getters and public properties that are not present in the constructor.
type UserMapped = { [P in keyof User]: User[P]; }?