Static methods with typescript & mongoose does: "An interface may only extend a class or another interface." Static methods with typescript & mongoose does: "An interface may only extend a class or another interface." mongoose mongoose

Static methods with typescript & mongoose does: "An interface may only extend a class or another interface."


As far I I know it is impossible to inherit from intersection/union types in typescript. And in case of mongoose type definitions mongoose.Model<T> is declared as intersection type:

type ModelConstructor<T> = IModelConstructor<T> & events.EventEmitter;

For examples of how to use mongoose in typescript you can check this topic on SA

But you still can use intersection instead of inheritance to get your required interface, like this:

interface IRoleDefinition{    myExtraProperty: string;}type IRole = mongoose.Model<IRoleDocument> & IRoleDefinition; 

More info about intersection types vs inheritance: github