@@ -11,7 +11,8 @@ import {
11
11
ModelStatic ,
12
12
GlobalModels ,
13
13
StoreState ,
14
- ModelInstance
14
+ ModelInstance ,
15
+ AnyData
15
16
} from './types'
16
17
import { globalModels , prepareAddModel } from './global-models'
17
18
import { mergeWithAccessors , checkNamespace , getId , Params } from '../utils'
@@ -54,28 +55,27 @@ function assertIsEventEmitter(val: unknown): asserts val is EventEmitter {
54
55
export default function makeBaseModel ( options : FeathersVuexOptions ) {
55
56
const addModel = prepareAddModel ( options )
56
57
const { serverAlias } = options
57
- type D = { }
58
58
59
59
// If this serverAlias already has a BaseModel, return it
60
60
const ExistingBaseModel = _get ( globalModels , `[${ serverAlias } ].BaseModel` )
61
61
if ( ExistingBaseModel ) {
62
- return ExistingBaseModel as ModelStatic < D >
62
+ return ExistingBaseModel as ModelStatic < AnyData >
63
63
}
64
64
65
- abstract class BaseModel implements ModelInstance < D > {
65
+ abstract class BaseModel implements ModelInstance < AnyData > {
66
66
// Think of these as abstract static properties
67
67
public static servicePath : string
68
68
public static namespace : string
69
69
public static keepCopiesInStore = options . keepCopiesInStore
70
70
// eslint-disable-next-line
71
- public static instanceDefaults ( data : Partial < D > , ctx : ModelSetupContext ) {
71
+ public static instanceDefaults ( data : Partial < AnyData > , ctx : ModelSetupContext ) {
72
72
return data
73
73
}
74
74
// eslint-disable-next-line
75
- public static setupInstance ( data : Partial < D > , ctx : ModelSetupContext ) {
75
+ public static setupInstance ( data : Partial < AnyData > , ctx : ModelSetupContext ) {
76
76
return data
77
77
}
78
- public static diffOnPatch ( data : Partial < D > ) {
78
+ public static diffOnPatch ( data : Partial < AnyData > ) {
79
79
return data
80
80
}
81
81
@@ -89,8 +89,8 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
89
89
90
90
public static readonly models = globalModels as GlobalModels // Can access other Models here
91
91
public static copiesById : {
92
- [ key : string ] : Model < D > | undefined
93
- [ key : number ] : Model < D > | undefined
92
+ [ key : string ] : Model < AnyData > | undefined
93
+ [ key : number ] : Model < AnyData > | undefined
94
94
} = { }
95
95
96
96
public __id : string
@@ -100,7 +100,7 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
100
100
public static merge = mergeWithAccessors
101
101
public static modelName = 'BaseModel'
102
102
103
- public constructor ( data : Partial < D > , options : ModelInstanceOptions ) {
103
+ public constructor ( data : Partial < AnyData > , options : ModelInstanceOptions ) {
104
104
// You have to pass at least an empty object to get a tempId.
105
105
data = data || { }
106
106
options = Object . assign ( { } , defaultOptions , options )
@@ -268,7 +268,7 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
268
268
/**
269
269
* clone the current record using the `createCopy` mutation
270
270
*/
271
- public clone ( data : Partial < D > ) : this {
271
+ public clone ( data : Partial < AnyData > ) : this {
272
272
const { idField, tempIdField } = this . constructor as typeof BaseModel
273
273
if ( this . __isClone ) {
274
274
throw new Error ( 'You cannot clone a copy' )
@@ -428,5 +428,5 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
428
428
429
429
const BaseModelEventEmitter = BaseModel
430
430
assertIsEventEmitter ( BaseModelEventEmitter )
431
- return BaseModelEventEmitter as ModelStatic < D >
431
+ return BaseModelEventEmitter as ModelStatic < AnyData >
432
432
}
0 commit comments