File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 1+ type Options = {
2+ [ key : string ] : unknown ;
3+ } ;
4+
15type ApiExtension = { [ key : string ] : any } ;
2- type TestPlugin = ( instance : Base ) => ApiExtension | undefined ;
6+ type TestPlugin = (
7+ instance : Base ,
8+ options : Options
9+ ) => ApiExtension | undefined ;
310type Constructor < T > = new ( ...args : any [ ] ) => T ;
411
512/**
@@ -33,12 +40,24 @@ export class Base {
3340 return BaseWithPlugins as typeof BaseWithPlugins & Constructor < Extension > ;
3441 }
3542
36- constructor ( ) {
43+ static defaults ( defaults : Options ) {
44+ return class OctokitWithDefaults extends this {
45+ constructor ( options : Options = { } ) {
46+ super ( Object . assign ( { } , defaults , options ) ) ;
47+ }
48+ } ;
49+ }
50+
51+ constructor ( options : Options = { } ) {
52+ this . options = options ;
53+
3754 // apply plugins
3855 // https://stackoverflow.com/a/16345172
3956 const classConstructor = this . constructor as typeof Base ;
4057 classConstructor . plugins . forEach ( plugin => {
41- Object . assign ( this , plugin ( this ) ) ;
58+ Object . assign ( this , plugin ( this , options ) ) ;
4259 } ) ;
4360 }
61+
62+ options : Options ;
4463}
You can’t perform that action at this time.
0 commit comments