File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11import { EventEmitter } from 'node:events' ;
22
3+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-empty-object-type
4+ interface AnyClass < InstanceType extends { } = { } > extends Function {
5+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6+ new ( ...args : any [ ] ) : InstanceType ;
7+ prototype : InstanceType ;
8+ }
9+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10+ export type AnyFunction = ( ...args : any ) => any ;
311export type Extension = Record < string , unknown > ;
412export type Plugin < T > = ( instance : T ) => Extension ;
513
14+ export const definePlugin = < T extends AnyClass , B extends AnyFunction = Plugin < T > > ( plugin : B ) : B => plugin ;
15+
616// https://stackoverflow.com/a/58603027
7- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8- export function withPlugins < TBase extends new ( ...args : any [ ] ) => any > ( Base : TBase ) {
17+ export function withPlugins < TBase extends AnyClass > ( Base : TBase ) {
918 return class ClassWithPlugins extends Base {
1019 static plugins : Plugin < ClassWithPlugins > [ ] ;
1120 static plugin < T extends Plugin < ClassWithPlugins > > ( plugin : T ) {
You can’t perform that action at this time.
0 commit comments