From 79ade0f6afca2073503f529bb73a96dedb2426af Mon Sep 17 00:00:00 2001 From: Alexandru Bereghici Date: Thu, 5 Oct 2023 11:21:19 +0300 Subject: [PATCH] chore: removed unnecessary type assertions --- .changeset/eleven-ducks-retire.md | 9 +++++++++ .../paste-core/components/breadcrumb/src/Breadcrumb.tsx | 6 ++++-- .../paste-core/components/checkbox/src/CheckboxGroup.tsx | 4 ++-- packages/paste-core/components/menu/src/MenuGroup.tsx | 4 ++-- packages/paste-core/layout/grid/src/Grid.tsx | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .changeset/eleven-ducks-retire.md diff --git a/.changeset/eleven-ducks-retire.md b/.changeset/eleven-ducks-retire.md new file mode 100644 index 0000000000..01a0eb9a2f --- /dev/null +++ b/.changeset/eleven-ducks-retire.md @@ -0,0 +1,9 @@ +--- +"@twilio-paste/breadcrumb": patch +"@twilio-paste/checkbox": patch +"@twilio-paste/menu": patch +"@twilio-paste/grid": patch +"@twilio-paste/core": patch +--- + +chore: removed unnecessary type assertions diff --git a/packages/paste-core/components/breadcrumb/src/Breadcrumb.tsx b/packages/paste-core/components/breadcrumb/src/Breadcrumb.tsx index 5f3a277bf1..ee96876e1e 100644 --- a/packages/paste-core/components/breadcrumb/src/Breadcrumb.tsx +++ b/packages/paste-core/components/breadcrumb/src/Breadcrumb.tsx @@ -125,7 +125,9 @@ const Breadcrumb = React.forwardRef( const [childrenCount, validChildren] = React.useMemo( () => [ React.Children.count(children), - React.Children.toArray(children).filter((child) => React.isValidElement(child) || typeof child === "string"), + React.Children.toArray(children).filter( + (child): child is React.ReactElement => React.isValidElement(child) || typeof child === "string", + ), ], [children], ); @@ -135,7 +137,7 @@ const Breadcrumb = React.forwardRef( {validChildren.map((child, index) => { - return React.cloneElement(child as React.ReactElement, { + return React.cloneElement(child, { last: childrenCount === index + 1, key: keySeed(`breadcrumb-${index}`), parentElement: element, diff --git a/packages/paste-core/components/checkbox/src/CheckboxGroup.tsx b/packages/paste-core/components/checkbox/src/CheckboxGroup.tsx index 46b6f5ac4a..6bd1cfb2ac 100644 --- a/packages/paste-core/components/checkbox/src/CheckboxGroup.tsx +++ b/packages/paste-core/components/checkbox/src/CheckboxGroup.tsx @@ -92,8 +92,8 @@ const CheckboxGroup = React.forwardRef( i18nRequiredLabel={i18nRequiredLabel} > {React.Children.map(children, (child, index) => { - return React.isValidElement(child) - ? React.cloneElement(child as React.ReactElement, { + return React.isValidElement(child) + ? React.cloneElement(child, { isSelectAll: isSelectAll && index === 0, isSelectAllChild: isSelectAll && orientation === "vertical" && index !== 0, }) diff --git a/packages/paste-core/components/menu/src/MenuGroup.tsx b/packages/paste-core/components/menu/src/MenuGroup.tsx index 9aad4ba025..61e6ce5b62 100644 --- a/packages/paste-core/components/menu/src/MenuGroup.tsx +++ b/packages/paste-core/components/menu/src/MenuGroup.tsx @@ -21,9 +21,9 @@ const MenuGroup = React.forwardRef( ref={ref} > - {React.isValidElement(icon) ? ( + {React.isValidElement(icon) ? ( - {React.cloneElement(icon as React.ReactElement, { color: "colorTextIcon" })} + {React.cloneElement(icon, { color: "colorTextIcon" })} ) : null} ( const GridColumns = React.useMemo( () => React.Children.map(children, (child) => - React.isValidElement(child) - ? React.cloneElement(child as React.ReactElement, { + React.isValidElement(child) + ? React.cloneElement(child, { count: React.Children.count(children), gutter, vertical,