-
-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathcomplex-store-inheritance.ts
More file actions
29 lines (23 loc) · 909 Bytes
/
complex-store-inheritance.ts
File metadata and controls
29 lines (23 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Thunk } from 'easy-peasy';
type Injections = any;
type ISomeOtherModel = {};
interface IModelA<TStore extends ISomeOtherModel> {
commitSomething: Thunk<
IModelAStoreModel<TStore>,
void,
Injections,
IModelAStoreModel<TStore>
>;
}
// IModelAStoreModel is generic, and requires the root store as input
type IModelAStoreModel<TStore extends ISomeOtherModel> = IModelA<TStore> &
ISomeOtherModel & {
onSomethingLoaded: Thunk<TStore, any>;
};
// IModelBStoreModel is not generic, and is based on IModelAStoreModel, but it does not care about the generic type
// of IModelAStoreModel (thus it is just passing`any` to`IModelAStoreModel`)
interface IModelBStoreModel extends IModelAStoreModel<any> {}
// IStoreModel should be allowed to extend both IModelAStoreModel & IModelBStoreModel
interface IStoreModel
extends IModelAStoreModel<IStoreModel>,
IModelBStoreModel {}