From 0ee359bccc0a8414e51f43f2582404a3b89a5765 Mon Sep 17 00:00:00 2001 From: crazyair <645381995@qq.com> Date: Sat, 29 Jul 2023 22:18:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20bool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/namePathType.ts | 2 +- tests/nameTypeCheck.test.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/namePathType.ts b/src/namePathType.ts index 74f9385b..66ced932 100644 --- a/src/namePathType.ts +++ b/src/namePathType.ts @@ -24,7 +24,7 @@ export type DeepNamePathBase = : | (ParentNamePath['length'] extends 0 ? FieldKey : never) // If `ParentNamePath` is empty, it can use `FieldKey` without array path | [...ParentNamePath, FieldKey] // Exist `ParentNamePath`, connect it - | (Store[FieldKey] extends (number | string)[] + | (Store[FieldKey] extends (number | string | boolean)[] ? [...ParentNamePath, FieldKey, number] // If `Store[FieldKey]` is base array type : Store[FieldKey] extends Record ? DeepNamePathBase // If `Store[FieldKey]` is object diff --git a/tests/nameTypeCheck.test.tsx b/tests/nameTypeCheck.test.tsx index 6ca5587b..114ea556 100644 --- a/tests/nameTypeCheck.test.tsx +++ b/tests/nameTypeCheck.test.tsx @@ -8,7 +8,7 @@ describe('nameTypeCheck', () => { type FieldType = { a: string; b?: string[]; - c?: { c1?: string; c2?: string[] }[]; + c?: { c1?: string; c2?: string[]; c3?: boolean[] }[]; d?: { d1?: string[]; d2?: string }; e?: { e1?: { e2?: string; e3?: string[]; e4: { e5: { e6: string } } } }; list?: { age?: string }[]; @@ -45,6 +45,8 @@ describe('nameTypeCheck', () => { name={['c', 1, 'c1']} /> name={['c', 1, 'c2']} /> name={['c', 1, 'c2', 1]} /> + name={['c', 1, 'c3']} /> + name={['c', 1, 'c3', 1]} /> name={['d', 'd1']} /> name={['d', 'd1', 1]} /> name={['d', 'd2']} />