@@ -27,7 +27,7 @@ type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction
2727 ? UnionToIntersection < ReturnType < T [ number ] > >
2828 : never ;
2929
30- export class Base {
30+ export class Base < TOptions extends Options = Options > {
3131 static plugins : TestPlugin [ ] = [ ] ;
3232 static plugin <
3333 S extends Constructor < any > & { plugins : any [ ] } ,
@@ -46,21 +46,25 @@ export class Base {
4646 ) ;
4747 } ;
4848
49- return BaseWithPlugins as typeof this & { plugins : any [ ] } &
50- Constructor < UnionToIntersection < ReturnTypeOf < T1 > & ReturnTypeOf < T2 > > > ;
49+ return BaseWithPlugins as typeof this & { plugins : any [ ] } & Constructor <
50+ UnionToIntersection < ReturnTypeOf < T1 > & ReturnTypeOf < T2 > >
51+ > ;
5152 }
5253
53- static defaults < S extends Constructor < any > > ( this : S , defaults : Options ) {
54+ static defaults <
55+ TDefaults extends Options ,
56+ S extends Constructor < Base < TDefaults > >
57+ > ( this : S , defaults : TDefaults ) {
5458 const BaseWitDefaults = class extends this {
5559 constructor ( ...args : any [ ] ) {
5660 super ( Object . assign ( { } , defaults , args [ 0 ] || { } ) ) ;
5761 }
5862 } ;
5963
60- return BaseWitDefaults as typeof this ;
64+ return BaseWitDefaults as typeof BaseWitDefaults & typeof this ;
6165 }
6266
63- constructor ( options : Options = { } ) {
67+ constructor ( options : TOptions = { } as TOptions ) {
6468 this . options = options ;
6569
6670 // apply plugins
@@ -71,5 +75,5 @@ export class Base {
7175 } ) ;
7276 }
7377
74- options : Options ;
75- }
78+ options : TOptions ;
79+ }
0 commit comments