How would I declare a type that is typeof B
and any class that extends B
? I've made a type that accepts an array of classes that extends the Component
class, but this isn't working on TSC 3.(1.4|2.1).
export class Component<S> {}
export type ComponentClass = new () => Component<{ message: string }>;
export interface ComponentFlags<S> {
imports?: (typeof Component | new () => Component<any>)[]
}
export class Message extends Component<State> {}
export class Dialog extends Component<State> {
constructor(el: HTMLDivElement) {
super({
imports: [Message]
});
}
}
This then raises an error when compiled.
type 'typeof Message' is not assignable to type 'typeof Component'.