Skip to content

Commit

Permalink
Fix TS build
Browse files Browse the repository at this point in the history
## Problem

The dependencies aren't fixed by a lock file, so builds can break without any change in the codebase

## Solution

1. Fix latest TS errors
2. Add a lockfile
  • Loading branch information
fzaninotto committed Jul 1, 2024
1 parent 5b191e2 commit 9bc45e6
Show file tree
Hide file tree
Showing 2 changed files with 12,353 additions and 16,742 deletions.
23 changes: 12 additions & 11 deletions src/hydra/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import type {
} from '../types.js';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isPlainObject = (value: any): value is object =>
const isPlainObject = (value: any): value is Record<string, any> =>
lodashIsPlainObject(value);

let apiSchema: Api & { resources: Resource[] };
Expand Down Expand Up @@ -287,16 +287,17 @@ function dataProvider(
).forEach(([key, value]) => {
// React-Admin FileInput format is an object containing a file.
if (containFile(value)) {
const findFile = (element: string | ToJSONObject): Blob =>
Object.values(element).find((val) => val instanceof File);
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
Array.isArray(value)
? value
.map((val) => findFile(val))
.forEach((file) => {
body.append(key.endsWith('[]') ? key : `${key}[]`, file);
})
: body.append(key, findFile(value));
const findFile = (element: string | ToJSONObject): Blob | undefined =>
Object.values(element).find((val) => val instanceof Blob);
if (Array.isArray(value)) {
value
.map((val) => findFile(val))
.forEach((file) => {
body.append(key.endsWith('[]') ? key : `${key}[]`, file!);
});
} else {
body.append(key, findFile(value)!);
}

return;
}
Expand Down
Loading

0 comments on commit 9bc45e6

Please sign in to comment.