File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,10 @@ type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction
2929
3030export class Base {
3131 static plugins : TestPlugin [ ] = [ ] ;
32- static plugin < T extends TestPlugin | TestPlugin [ ] > ( plugin : T ) {
32+ static plugin <
33+ S extends Constructor < any > & { plugins : any [ ] } ,
34+ T extends TestPlugin | TestPlugin [ ]
35+ > ( this : S , plugin : T ) {
3336 const currentPlugins = this . plugins ;
3437
3538 const BaseWithPlugins = class extends this {
@@ -40,12 +43,14 @@ export class Base {
4043 return BaseWithPlugins as typeof BaseWithPlugins & Constructor < Extension > ;
4144 }
4245
43- static defaults ( defaults : Options ) {
44- return class OctokitWithDefaults extends this {
45- constructor ( options : Options = { } ) {
46- super ( Object . assign ( { } , defaults , options ) ) ;
46+ static defaults < S extends Constructor < any > > ( this : S , defaults : Options ) {
47+ const OctokitWithDefaults = class extends this {
48+ constructor ( ... args : any [ ] ) {
49+ super ( Object . assign ( { } , defaults , args [ 0 ] || { } ) ) ;
4750 }
4851 } ;
52+
53+ return OctokitWithDefaults ;
4954 }
5055
5156 constructor ( options : Options = { } ) {
You can’t perform that action at this time.
0 commit comments