From dd85615643583e9c8f1a6fc21f0fae36a0747d83 Mon Sep 17 00:00:00 2001 From: Chris Villa Date: Thu, 21 Sep 2023 15:13:22 +0100 Subject: [PATCH 1/2] fix: add missing id type to render props --- packages/core/components/Render/index.tsx | 2 +- packages/core/types/Config.tsx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/components/Render/index.tsx b/packages/core/components/Render/index.tsx index 7010f1ced..966bffe89 100644 --- a/packages/core/components/Render/index.tsx +++ b/packages/core/components/Render/index.tsx @@ -8,7 +8,7 @@ export function Render({ config, data }: { config: Config; data: Data }) { if (config.root) { return ( - + diff --git a/packages/core/types/Config.tsx b/packages/core/types/Config.tsx index 0db7feede..305b18cc7 100644 --- a/packages/core/types/Config.tsx +++ b/packages/core/types/Config.tsx @@ -8,6 +8,10 @@ export type Adaptor = { ) => Promise[] | null>; }; +type WithId = T & { + id: string; +}; + export type Field< Props extends { [key: string]: any } = { [key: string]: any } > = { @@ -67,7 +71,7 @@ export type ComponentConfig< ComponentProps extends DefaultComponentProps = DefaultComponentProps, DefaultProps = ComponentProps > = { - render: (props: ComponentProps) => ReactElement; + render: (props: WithId) => ReactElement; defaultProps?: DefaultProps; fields?: Fields; }; @@ -91,9 +95,9 @@ export type Config< type MappedItem = { type: keyof Props; - props: { + props: WithId<{ [key: string]: any; - } & { id: string }; + }>; }; export type Data< From 1ad5a2f2d4c0df8ad16726d636b0fc2a862730b2 Mon Sep 17 00:00:00 2001 From: Chris Villa Date: Thu, 21 Sep 2023 15:13:46 +0100 Subject: [PATCH 2/2] fix: ensure types allow for nested arrays --- packages/core/types/Config.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/types/Config.tsx b/packages/core/types/Config.tsx index 305b18cc7..c8022f016 100644 --- a/packages/core/types/Config.tsx +++ b/packages/core/types/Config.tsx @@ -28,7 +28,7 @@ export type Field< adaptor?: Adaptor; adaptorParams?: object; arrayFields?: { - [SubPropName in keyof Props]: Field; + [SubPropName in keyof Props]: Field; }; getItemSummary?: (item: Props, index?: number) => string; defaultItemProps?: Props;