Skip to content

Commit

Permalink
Fix more TS warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Feb 5, 2024
1 parent 1e3183c commit 1d45fbb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/ra-core/src/core/useResourceDefinitions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ResourceDefinitions } from './ResourceDefinitionContext';
import type { ResourceOptions } from '../types';
import type { ResourceDefinitions } from './ResourceDefinitionContext';
import { useResourceDefinitionContext } from './useResourceDefinitionContext';

/**
Expand All @@ -20,6 +21,6 @@ import { useResourceDefinitionContext } from './useResourceDefinitionContext';
* // }
*/
export const useResourceDefinitions = <
OptionsType = any
OptionsType extends ResourceOptions = any
>(): ResourceDefinitions<OptionsType> =>
useResourceDefinitionContext().definitions;
2 changes: 1 addition & 1 deletion packages/ra-core/src/dataProvider/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const isValidObject = value => {
return !isArray && !isBuffer && isObject && hasKeys;
};

export const flattenObject = (value, path = []) => {
export const flattenObject = (value: any, path: string[] = []) => {
if (isValidObject(value)) {
return Object.assign(
{},
Expand Down
6 changes: 5 additions & 1 deletion packages/ra-core/src/form/useUnique.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ export const useUnique = (options?: UseUniqueOptions) => {
}
);

if (total > 0 && !data.some(r => r.id === record?.id)) {
if (
typeof total !== 'undefined' &&
total > 0 &&
!data.some(r => r.id === record?.id)
) {
return {
message,
args: {
Expand Down

0 comments on commit 1d45fbb

Please sign in to comment.