From 6fc2c62f6fd4400addc17a94839996815d9c3e76 Mon Sep 17 00:00:00 2001 From: plus Date: Wed, 12 Feb 2025 12:55:21 +0800 Subject: [PATCH 1/2] fix: Fix handling of specific array types in auto API components - Resolved logic errors when processing fixed-length tuple types such as [number, number]. - Enhanced type inference to ensure accurate handling of array types during component generation. This update improves the compatibility and stability of auto API components with complex array types. --- src/client/theme-default/builtins/API/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/client/theme-default/builtins/API/index.tsx b/src/client/theme-default/builtins/API/index.tsx index 836e2db96..cd74ac7bc 100644 --- a/src/client/theme-default/builtins/API/index.tsx +++ b/src/client/theme-default/builtins/API/index.tsx @@ -100,9 +100,21 @@ const HANDLERS = { ); }, - array(prop: Extract): ReactNode { + array(prop: Extract & { items?: any[] }): ReactNode { let arrayType: ReactNode = any; if (prop.items) { + if (Array.isArray(prop.items)) return ( + + {'['} + {prop.items.map((item: Extract, i) => ( + + {i > 0 && ', '} + {this.toNode(item)} + + ))} + {']'} + + ); const className = this.getValidClassName(prop.items); arrayType = className ?? this.toNode(prop.items); } From 1b5b69b6237a7593f3a658bfa231d7c20aa8d9eb Mon Sep 17 00:00:00 2001 From: plus Date: Thu, 13 Feb 2025 10:33:46 +0800 Subject: [PATCH 2/2] fix: type --- src/client/theme-default/builtins/API/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/theme-default/builtins/API/index.tsx b/src/client/theme-default/builtins/API/index.tsx index cd74ac7bc..ab5dd4b40 100644 --- a/src/client/theme-default/builtins/API/index.tsx +++ b/src/client/theme-default/builtins/API/index.tsx @@ -106,7 +106,7 @@ const HANDLERS = { if (Array.isArray(prop.items)) return ( {'['} - {prop.items.map((item: Extract, i) => ( + {prop.items.map((item, i) => ( {i > 0 && ', '} {this.toNode(item)}