ComponentConstructor

type ComponentConstructor

type ComponentConstructor<TComponent extends Component = Component> = new (...args: never[]) => TComponent;

Generic constructor type for Component classes.

This type is used to define parameters of Component.preset.

Example

export class Application extends Component {
  static preset(
    presets: Application.Presets,
    ...activities: Array<ComponentConstructor | undefined>
  ): Function {
    // ... use preset activities here
  }
  // ...
}

ComponentConstructor.PresetType

type PresetType<TComponentCtor extends ComponentConstructor> = TComponentCtor extends {
preset: (presets: infer TPreset) => void;
} ? TPreset : any;

Inferred partial type of the argument to Component.with without bindings, for a specific component constructor.


ComponentConstructor.PresetArgType

type PresetArgType<TComponentCtor extends ComponentConstructor> = {
[P in keyof PresetType<TComponentCtor>]?:PresetType<TComponentCtor>[P] | Binding.Type;
} & {
[P: string]: any;
};

Inferred type of the argument to Component.with for a specific component constructor.


ComponentConstructor.PresetRestType

type PresetRestType<TComponentCtor extends ComponentConstructor> = TComponentCtor extends {
preset: (presets:PresetType<TComponentCtor>, ...rest: infer TRest) => void;
} ? TRest : never;

Inferred type of the rest arguments to Component.with for a specific component constructor.