Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/declarations/stencil-public-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ declare type CustomMethodDecorator<T> = (

type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;

type MixinFactory = <TBase extends abstract new (...args: any[]) => any>(
base: TBase,
) => abstract new (...args: ConstructorParameters<TBase>) => any;

export interface ComponentDecorator {
(opts?: ComponentOptions): ClassDecorator;
}
Expand Down Expand Up @@ -407,15 +403,21 @@ export declare function readTask(task: RafCallback): void;
*/
export declare const setErrorHandler: (handler: ErrorHandler) => void;

export type MixinFactory = <TBase extends new (...args: any[]) => any>(
base: TBase,
) => abstract new (...args: ConstructorParameters<TBase>) => any;

/**
* Compose multiple mixin classes into a single constructor.
* The resulting class has the combined instance types of all mixed-in classes.
*
* Example:
* ```
* const AWrap = (Base) => {class A extends Base { propA = A }; return A;}
* const BWrap = (Base) => {class B extends Base { propB = B }; return B;}
* const CWrap = (Base) => {class C extends Base { propC = C }; return C;}
* import { Mixin, MixinFactory } from '@stencil/core';
*
* const AWrap: MixinFactory = (Base) => {class A extends Base { propA = A }; return A;}
* const BWrap: MixinFactory = (Base) => {class B extends Base { propB = B }; return B;}
* const CWrap: MixinFactory = (Base) => {class C extends Base { propC = C }; return C;}
*
* class X extends Mixin(AWrap, BWrap, CWrap) {
* render() { return <div>{this.propA} {this.propB} {this.propC}</div>; }
Expand Down
1 change: 1 addition & 0 deletions src/internal/stencil-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export {
Listen,
Method,
Mixin,
MixinFactory,
Prop,
readTask,
render,
Expand Down
Loading