// @strict: true // @target: es2017 // #41347, based on microsoft/rushstack // Mixin utilities export type Constructor = new (...args: any[]) => T; export type PropertiesOf = { [K in keyof T]: T[K] }; interface IApiItemConstructor extends Constructor, PropertiesOf {} // Base class class ApiItem { public get members(): ReadonlyArray { return []; } } // Normal subclass class ApiEnumMember extends ApiItem { } // Mixin base class interface ApiItemContainerMixin extends ApiItem { readonly members: ReadonlyArray; } function ApiItemContainerMixin( baseClass: TBaseClass ): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) { abstract class MixedClass extends baseClass implements ApiItemContainerMixin { public constructor(...args: any[]) { super(...args); } public get members(): ReadonlyArray { return []; } } return MixedClass; } // Subclass inheriting from mixin export class ApiEnum extends ApiItemContainerMixin(ApiItem) { // This worked prior to TypeScript 4.0: public get members(): ReadonlyArray { return []; } }