Skip to content

Commit 65deef8

Browse files
committed
better type
1 parent 32a6c10 commit 65deef8

File tree

1 file changed

+7
-5
lines changed
  • packages/ra-data-local-storage/src

1 file changed

+7
-5
lines changed

packages/ra-data-local-storage/src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable eqeqeq */
21
import fakeRestProvider from 'ra-data-fakerest';
32
import { DataProvider, RaRecord } from 'ra-core';
43
import pullAt from 'lodash/pullAt.js';
@@ -255,31 +254,34 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => {
255254
};
256255
};
257256

258-
const getResourceCollection = (data, resource) => {
257+
const getResourceCollection = (data: Record<string, any>, resource: string) => {
259258
if (!Object.prototype.hasOwnProperty.call(data, resource)) {
260259
throw new Error(`Unknown resource key: ${resource}`);
261260
}
262261

263262
return data[resource];
264263
};
265264

266-
const getOrCreateResourceCollection = (data, resource) => {
265+
const getOrCreateResourceCollection = (
266+
data: Record<string, any>,
267+
resource: string
268+
) => {
267269
if (!Object.prototype.hasOwnProperty.call(data, resource)) {
268270
data[resource] = [];
269271
}
270272

271273
return data[resource];
272274
};
273275

274-
const checkResource = resource => {
276+
const checkResource = (resource: string) => {
275277
// Reject "__proto__" so dynamic writes like data[resource] = value don't
276278
// mutate Object.prototype instead of creating a normal resource collection.
277279
if (resource === '__proto__') {
278280
throw new Error(`Invalid resource key: ${resource}`);
279281
}
280282
};
281283

282-
const assertRecordsExist = (resourceData, ids) => {
284+
const assertRecordsExist = (resourceData: any[], ids: any[]) => {
283285
ids.forEach(id => {
284286
if (resourceData.findIndex(record => record.id == id) === -1) {
285287
throw new Error(`No item with identifier ${id}`);

0 commit comments

Comments
 (0)