Skip to content

Commit 81cfc86

Browse files
committed
Fix typings
1 parent ecfa94e commit 81cfc86

21 files changed

+125
-98
lines changed

dist/vuex-orm-graphql.es5.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-orm-graphql.es5.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-orm-graphql.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-orm-graphql.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,7 @@
149149
],
150150
"collectCoverageFrom": [
151151
"src/**/*.{js,ts}"
152-
],
153-
"globals": {
154-
"ts-jest": {
155-
"diagnostics": {
156-
"ignoreCodes": [2339, 2576]
157-
}
158-
}
159-
}
152+
]
160153
},
161154
"commitlint": {
162155
"extends": [

src/actions/action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class Action {
4646
newData.id = parseInt(newData.id, 10);
4747

4848
const insertedData: Data = await Store.insertData(
49-
{ [model.pluralName]: newData },
49+
{ [model.pluralName]: newData } as Data,
5050
dispatch
5151
);
5252

@@ -117,7 +117,7 @@ export default class Action {
117117
const context = Context.getInstance();
118118

119119
Object.keys(args).forEach((key: string) => {
120-
const value: any = args[key];
120+
const value: Data = args[key];
121121

122122
if (value instanceof context.components.Model) {
123123
const model = context.getModel(singularize(value.$self().entity));

src/actions/destroy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActionParams } from "../support/interfaces";
1+
import { ActionParams, Data } from "../support/interfaces";
22
import Action from "./action";
33
import { Store } from "../orm/store";
44
import Context from "../common/context";
@@ -30,7 +30,7 @@ export default class Destroy extends Action {
3030

3131
args = this.prepareArgs(args, id);
3232

33-
await Action.mutation(mutationName, args, dispatch!, model);
33+
await Action.mutation(mutationName, args as Data, dispatch!, model);
3434
return true;
3535
} else {
3636
/* istanbul ignore next */

src/actions/fetch.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import QueryBuilder from "../graphql/query-builder";
22
import Context from "../common/context";
33
import { Store } from "../orm/store";
44
import Transformer from "../graphql/transformer";
5-
import { ActionParams, Data } from "../support/interfaces";
5+
import { ActionParams, Arguments, Data } from "../support/interfaces";
66
import Action from "./action";
77

88
/**
@@ -33,10 +33,15 @@ export default class Fetch extends Action {
3333
await context.loadSchema();
3434

3535
// Filter
36-
const filter =
37-
params && params.filter
38-
? Transformer.transformOutgoingData(model, params.filter, Object.keys(params.filter))
39-
: {};
36+
let filter = {};
37+
38+
if (params && params.filter) {
39+
filter = Transformer.transformOutgoingData(
40+
model,
41+
params.filter as Data,
42+
Object.keys(params.filter)
43+
);
44+
}
4045

4146
const bypassCache = params && params.bypassCache;
4247

src/actions/mutate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default class Mutate extends Action {
4141
this.transformArgs(args);
4242

4343
// Send the mutation
44-
return Action.mutation(name, args, dispatch!, model);
44+
return Action.mutation(name, args as Data, dispatch!, model);
4545
} else {
4646
/* istanbul ignore next */
4747
throw new Error("The mutate action requires the mutation name ('mutation') to be set");

src/actions/persist.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ export default class Persist extends Action {
2121
if (id) {
2222
const model = this.getModelFromState(state!);
2323
const mutationName = Context.getInstance().adapter.getNameForPersist(model);
24-
const oldRecord = model.getRecordWithId(id);
24+
const oldRecord = model.getRecordWithId(id)!;
2525

2626
const mockReturnValue = model.$mockHook("persist", {
2727
id,
2828
args: args || {}
2929
});
3030

3131
if (mockReturnValue) {
32-
const newRecord = Store.insertData(mockReturnValue, dispatch!);
32+
const newRecord = await Store.insertData(mockReturnValue, dispatch!);
3333
await this.deleteObsoleteRecord(model, newRecord, oldRecord);
3434
return newRecord;
3535
}
@@ -39,7 +39,7 @@ export default class Persist extends Action {
3939
this.addRecordToArgs(args, model, oldRecord);
4040

4141
// Send mutation
42-
const newRecord = await Action.mutation(mutationName, args, dispatch!, model);
42+
const newRecord = await Action.mutation(mutationName, args as Data, dispatch!, model);
4343

4444
// Delete the old record if necessary
4545
await this.deleteObsoleteRecord(model, newRecord, oldRecord);
@@ -64,5 +64,7 @@ export default class Persist extends Action {
6464
Context.getInstance().logger.log("Dropping deprecated record", oldRecord);
6565
return oldRecord.$delete();
6666
}
67+
68+
return null;
6769
}
6870
}

0 commit comments

Comments
 (0)