From 20691c0478369da2a62d1c068345aa6e465aa3a0 Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2025 20:00:34 +0100 Subject: [PATCH 1/3] fix(Mixin): export `MixinFactory` for ease of use --- src/declarations/stencil-public-runtime.ts | 16 +++++++++------- src/internal/stencil-core/index.d.ts | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/declarations/stencil-public-runtime.ts b/src/declarations/stencil-public-runtime.ts index ec93403edc4..968c7b79835 100644 --- a/src/declarations/stencil-public-runtime.ts +++ b/src/declarations/stencil-public-runtime.ts @@ -6,10 +6,6 @@ declare type CustomMethodDecorator = ( type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never; -type MixinFactory = any>( - base: TBase, -) => abstract new (...args: ConstructorParameters) => any; - export interface ComponentDecorator { (opts?: ComponentOptions): ClassDecorator; } @@ -407,15 +403,21 @@ export declare function readTask(task: RafCallback): void; */ export declare const setErrorHandler: (handler: ErrorHandler) => void; +export type MixinFactory = any>( + base: TBase, +) => abstract new (...args: ConstructorParameters) => 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
{this.propA} {this.propB} {this.propC}
; } diff --git a/src/internal/stencil-core/index.d.ts b/src/internal/stencil-core/index.d.ts index 71ece2c6f6d..25c4c5b7e05 100644 --- a/src/internal/stencil-core/index.d.ts +++ b/src/internal/stencil-core/index.d.ts @@ -40,6 +40,7 @@ export { Listen, Method, Mixin, + MixinFactory, Prop, readTask, render, From a701b70165e0f7f912ce08907d30908429f7d7eb Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2025 20:01:10 +0100 Subject: [PATCH 2/3] chore: prettier --- src/declarations/stencil-public-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarations/stencil-public-runtime.ts b/src/declarations/stencil-public-runtime.ts index 968c7b79835..dca11c6d13a 100644 --- a/src/declarations/stencil-public-runtime.ts +++ b/src/declarations/stencil-public-runtime.ts @@ -414,7 +414,7 @@ export type MixinFactory = any>( * Example: * ``` * 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;} From f03f77f616018e3bf464d88bdba309a2a615034c Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2025 20:10:08 +0100 Subject: [PATCH 3/3] chore: loosen type slightly --- src/declarations/stencil-public-runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarations/stencil-public-runtime.ts b/src/declarations/stencil-public-runtime.ts index dca11c6d13a..4a847fa217a 100644 --- a/src/declarations/stencil-public-runtime.ts +++ b/src/declarations/stencil-public-runtime.ts @@ -403,7 +403,7 @@ export declare function readTask(task: RafCallback): void; */ export declare const setErrorHandler: (handler: ErrorHandler) => void; -export type MixinFactory = any>( +export type MixinFactory = any>( base: TBase, ) => abstract new (...args: ConstructorParameters) => any;