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
29
29
30
30
export class Base {
31
31
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 ) {
33
36
const currentPlugins = this . plugins ;
34
37
35
38
const BaseWithPlugins = class extends this {
@@ -40,12 +43,14 @@ export class Base {
40
43
return BaseWithPlugins as typeof BaseWithPlugins & Constructor < Extension > ;
41
44
}
42
45
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 ] || { } ) ) ;
47
50
}
48
51
} ;
52
+
53
+ return OctokitWithDefaults ;
49
54
}
50
55
51
56
constructor ( options : Options = { } ) {
You can’t perform that action at this time.
0 commit comments