Open god-of-javascript opened 1 year ago
I figured out that we can do:
ReturnType<typeof CLASS.prototype.toObject>
or
const instance = new CLASS().toObject();
type YourType = typeof instance;
it was better to export this with the generated files
I have created this generic type to get class type!
/**
* Get type of proto class
*/
export type GetTypeOf<T> = ReturnType<InstanceType<T>["toObject"]>;
const a:GetTypeOf<typeof Class> = {
// type safe object
}
Image I have this message:
How can I get the type of
LoginRequest
? I triedtypeof
but it doesn't work!