Skip to content

Commit 9e5ed65

Browse files
committed
better type
1 parent 32a6c10 commit 9e5ed65

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • packages/ra-data-local-storage/src

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,31 +255,34 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => {
255255
};
256256
};
257257

258-
const getResourceCollection = (data, resource) => {
258+
const getResourceCollection = (data: Record<string, any>, resource: string) => {
259259
if (!Object.prototype.hasOwnProperty.call(data, resource)) {
260260
throw new Error(`Unknown resource key: ${resource}`);
261261
}
262262

263263
return data[resource];
264264
};
265265

266-
const getOrCreateResourceCollection = (data, resource) => {
266+
const getOrCreateResourceCollection = (
267+
data: Record<string, any>,
268+
resource: string
269+
) => {
267270
if (!Object.prototype.hasOwnProperty.call(data, resource)) {
268271
data[resource] = [];
269272
}
270273

271274
return data[resource];
272275
};
273276

274-
const checkResource = resource => {
277+
const checkResource = (resource: string) => {
275278
// Reject "__proto__" so dynamic writes like data[resource] = value don't
276279
// mutate Object.prototype instead of creating a normal resource collection.
277280
if (resource === '__proto__') {
278281
throw new Error(`Invalid resource key: ${resource}`);
279282
}
280283
};
281284

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

0 commit comments

Comments
 (0)