@@ -27,7 +27,7 @@ type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction
27
27
? UnionToIntersection < ReturnType < T [ number ] > >
28
28
: never ;
29
29
30
- export class Base {
30
+ export class Base < TOptions extends Options = Options > {
31
31
static plugins : TestPlugin [ ] = [ ] ;
32
32
static plugin <
33
33
S extends Constructor < any > & { plugins : any [ ] } ,
@@ -46,21 +46,25 @@ export class Base {
46
46
) ;
47
47
} ;
48
48
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
+ > ;
51
52
}
52
53
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 ) {
54
58
const BaseWitDefaults = class extends this {
55
59
constructor ( ...args : any [ ] ) {
56
60
super ( Object . assign ( { } , defaults , args [ 0 ] || { } ) ) ;
57
61
}
58
62
} ;
59
63
60
- return BaseWitDefaults as typeof this ;
64
+ return BaseWitDefaults as typeof BaseWitDefaults & typeof this ;
61
65
}
62
66
63
- constructor ( options : Options = { } ) {
67
+ constructor ( options : TOptions = { } as TOptions ) {
64
68
this . options = options ;
65
69
66
70
// apply plugins
@@ -71,5 +75,5 @@ export class Base {
71
75
} ) ;
72
76
}
73
77
74
- options : Options ;
75
- }
78
+ options : TOptions ;
79
+ }
0 commit comments