From 1c53619eca8f32395e2d8b2c0508ac5ced5406c2 Mon Sep 17 00:00:00 2001 From: Chris Villa Date: Fri, 31 Jan 2025 12:27:38 +0000 Subject: [PATCH] refactor: reorder FieldProps generics so TS can infer type --- packages/core/components/AutoField/index.tsx | 10 +++++----- packages/core/types/API/Overrides.ts | 2 +- packages/core/types/Fields.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/components/AutoField/index.tsx b/packages/core/components/AutoField/index.tsx index 54ab249060..687528cecf 100644 --- a/packages/core/components/AutoField/index.tsx +++ b/packages/core/components/AutoField/index.tsx @@ -103,8 +103,8 @@ export const FieldLabelInternal = ({ }; type FieldPropsInternalOptional> = FieldProps< - ValueType, - F + F, + ValueType > & { Label?: React.FC; label?: string; @@ -112,8 +112,8 @@ type FieldPropsInternalOptional> = FieldProps< }; export type FieldPropsInternal> = FieldProps< - ValueType, - F + F, + ValueType > & { Label: React.FC; label?: string; @@ -293,7 +293,7 @@ export function AutoFieldPrivate< export function AutoField< ValueType = any, FieldType extends FieldNoLabel = FieldNoLabel ->(props: FieldProps) { +>(props: FieldProps) { const DefaultLabel = useMemo(() => { const DefaultLabel = (labelProps: any) => (
> & { + FieldProps, any> & { children: ReactNode; name: string; } diff --git a/packages/core/types/Fields.ts b/packages/core/types/Fields.ts index 2738d0c05b..f03f1d0dcc 100644 --- a/packages/core/types/Fields.ts +++ b/packages/core/types/Fields.ts @@ -132,7 +132,7 @@ export type Fields< >; }; -export type FieldProps> = { +export type FieldProps, ValueType = any> = { field: F; value: ValueType; id?: string;