UNPKG

@juzi/wechaty

Version:

Wechaty is a RPA SDK for Chatbot Makers.

32 lines 1.27 kB
/** * Class mixins are a pattern for sharing code between classes using standard JavaScript. * https://lit.dev/docs/composition/mixins/ */ import type { Constructor } from 'clone-class'; interface PoolifyMixin<T> { new (...args: any[]): T; pool: Map<string, T>; } /** * https://stackoverflow.com/a/60378737/1123955 * * You want something like partial type parameter inference, * which is not currently a feature of TypeScript (see microsoft/TypeScript#26242). * Right now you either have to specify all type parameters manually * or let the compiler infer all type parameters; * there's no partial inference. * As you've noticed, * generic type parameter defaults do not scratch this itch; * a default turns off inference. */ declare const poolifyMixin: <MixinBase extends Constructor<{}, {}>>(mixinBase: MixinBase) => <T>() => ((abstract new (...args: any[]) => {}) & { _pool?: Map<string, T> | undefined; readonly pool: Map<string, T>; load<L extends import("clone-class/dist/esm/src/constructor").ClassInterface<{}> & { new (...args: any[]): T; prototype: T; } & PoolifyMixin<T>>(this: L, id: string): T; }) & MixinBase; export type { PoolifyMixin, }; export { poolifyMixin, }; //# sourceMappingURL=poolify.d.ts.map