Классы миксины в TypeScript

Пример миксина:

export type CardConstructorOptions = { [key: string]: any };

type Constructor<T> = new (...args: any[]) => T;

class Card {
  log() {
    console.log('Card');
  }
}

export function mixinContent<T extends Constructor<Card>>(super_class: T) {
  return class ContentMixin extends super_class {
    content() {
      console.log('content');
    }
  };
}

type ClassCard<T> = {
  [key: string]: Constructor<T>;
}

class CardContent extends mixinContent(Card) {

}

class Container {


  static create (name:string, options: CardConstructorOptions) {
    return new Container.store[name](options);
  }

  static get store(): ClassCard<Card|CardContent> {
    return {
      Card,
      CardContent,
    }
  }

}

const card = Container.create('CardContent', {}) as CardContent;

card.content();

Почему я не могу типизировать аргумент конструктора так:

type Constructor<T> = new (options: CardConstructorOptions) => T;

Получаю ошибку:

A mixin class must have a constructor with a single rest parameter of type 'any[]'.

Песочница.


Ответы (0 шт):