Skip to content

Commit 742f246

Browse files
committed
cleanup: don't use local type in make-base-model
1 parent 77f9c18 commit 742f246

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/service-module/make-base-model.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
ModelStatic,
1212
GlobalModels,
1313
StoreState,
14-
ModelInstance
14+
ModelInstance,
15+
AnyData
1516
} from './types'
1617
import { globalModels, prepareAddModel } from './global-models'
1718
import { mergeWithAccessors, checkNamespace, getId, Params } from '../utils'
@@ -54,28 +55,27 @@ function assertIsEventEmitter(val: unknown): asserts val is EventEmitter {
5455
export default function makeBaseModel(options: FeathersVuexOptions) {
5556
const addModel = prepareAddModel(options)
5657
const { serverAlias } = options
57-
type D = {}
5858

5959
// If this serverAlias already has a BaseModel, return it
6060
const ExistingBaseModel = _get(globalModels, `[${serverAlias}].BaseModel`)
6161
if (ExistingBaseModel) {
62-
return ExistingBaseModel as ModelStatic<D>
62+
return ExistingBaseModel as ModelStatic<AnyData>
6363
}
6464

65-
abstract class BaseModel implements ModelInstance<D> {
65+
abstract class BaseModel implements ModelInstance<AnyData> {
6666
// Think of these as abstract static properties
6767
public static servicePath: string
6868
public static namespace: string
6969
public static keepCopiesInStore = options.keepCopiesInStore
7070
// eslint-disable-next-line
71-
public static instanceDefaults(data: Partial<D>, ctx: ModelSetupContext) {
71+
public static instanceDefaults(data: Partial<AnyData>, ctx: ModelSetupContext) {
7272
return data
7373
}
7474
// eslint-disable-next-line
75-
public static setupInstance(data: Partial<D>, ctx: ModelSetupContext) {
75+
public static setupInstance(data: Partial<AnyData>, ctx: ModelSetupContext) {
7676
return data
7777
}
78-
public static diffOnPatch(data: Partial<D>) {
78+
public static diffOnPatch(data: Partial<AnyData>) {
7979
return data
8080
}
8181

@@ -89,8 +89,8 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
8989

9090
public static readonly models = globalModels as GlobalModels // Can access other Models here
9191
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
9494
} = {}
9595

9696
public __id: string
@@ -100,7 +100,7 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
100100
public static merge = mergeWithAccessors
101101
public static modelName = 'BaseModel'
102102

103-
public constructor(data: Partial<D>, options: ModelInstanceOptions) {
103+
public constructor(data: Partial<AnyData>, options: ModelInstanceOptions) {
104104
// You have to pass at least an empty object to get a tempId.
105105
data = data || {}
106106
options = Object.assign({}, defaultOptions, options)
@@ -268,7 +268,7 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
268268
/**
269269
* clone the current record using the `createCopy` mutation
270270
*/
271-
public clone(data: Partial<D>): this {
271+
public clone(data: Partial<AnyData>): this {
272272
const { idField, tempIdField } = this.constructor as typeof BaseModel
273273
if (this.__isClone) {
274274
throw new Error('You cannot clone a copy')
@@ -428,5 +428,5 @@ export default function makeBaseModel(options: FeathersVuexOptions) {
428428

429429
const BaseModelEventEmitter = BaseModel
430430
assertIsEventEmitter(BaseModelEventEmitter)
431-
return BaseModelEventEmitter as ModelStatic<D>
431+
return BaseModelEventEmitter as ModelStatic<AnyData>
432432
}

0 commit comments

Comments
 (0)