Given a class, containing both properties and methods, I’d like to derive a type that just contains its properties.

    For example, if I define a class as follow:

    1. class MyObject {
    2. constructor(public prop1: string, public prop2: number) {}
    3. instanceMethod() { ... }
    4. }

    I’d like to have a type, say MyObjectConstructor that would be like this:

    type MyObjectConstructor = {
      prop1: string;
      prop2: string;
    }
    

    I know I can use the built-in type Pick and manually select the keys I want by name, but I don’t want to have to repeat the keys all over, and have to change them every time I add new properties to my class.

    Is there a way to define a generic type ConstructorType<T>that only returns the properties of a class in typescript ?
    https://stackoverflow.com/questions/55479658/how-to-create-a-type-excluding-instance-methods-from-a-class-in-typescript