From e68c90c3223f08c230ba4602b259438238cda31e Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 29 Apr 2021 12:12:23 -0400 Subject: [PATCH 1/2] Update isCustomProps to accept "otherProps" --- src/components/grid/Grid/Grid.tsx | 38 ++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/components/grid/Grid/Grid.tsx b/src/components/grid/Grid/Grid.tsx index d32fc49cc9..79ab896622 100644 --- a/src/components/grid/Grid/Grid.tsx +++ b/src/components/grid/Grid/Grid.tsx @@ -26,7 +26,39 @@ export type CustomGridProps = GridComponentProps< WithCustomGridProps> export function isCustomProps( - props: DefaultGridProps | CustomGridProps + props: + | Omit< + DefaultGridProps, + | 'mobile' + | 'tablet' + | 'desktop' + | 'widescreen' + | 'mobileLg' + | 'tabletLg' + | 'desktopLg' + | 'children' + | 'className' + | 'row' + | 'col' + | 'gap' + | 'offset' + > + | Omit< + CustomGridProps, + | 'mobile' + | 'tablet' + | 'desktop' + | 'widescreen' + | 'mobileLg' + | 'tabletLg' + | 'desktopLg' + | 'children' + | 'className' + | 'row' + | 'col' + | 'gap' + | 'offset' + > ): props is CustomGridProps { return 'asCustom' in props } @@ -118,8 +150,8 @@ export function Grid( classes = classnames(classes, className) - if (isCustomProps(props)) { - const { asCustom, ...remainingProps } = props + if (isCustomProps(otherProps)) { + const { asCustom, ...remainingProps } = otherProps const gridProps: FCProps = (remainingProps as unknown) as FCProps return React.createElement( From c6f48178aba0c82f96edd4a32587abe5a179a78f Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 29 Apr 2021 12:15:04 -0400 Subject: [PATCH 2/2] Refactor out ommited props --- src/components/grid/Grid/Grid.tsx | 51 +++++++++++-------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/src/components/grid/Grid/Grid.tsx b/src/components/grid/Grid/Grid.tsx index 79ab896622..060fee53bc 100644 --- a/src/components/grid/Grid/Grid.tsx +++ b/src/components/grid/Grid/Grid.tsx @@ -25,41 +25,26 @@ export type CustomGridProps = GridComponentProps< > & WithCustomGridProps> +type omittedProps = + | 'mobile' + | 'tablet' + | 'desktop' + | 'widescreen' + | 'mobileLg' + | 'tabletLg' + | 'desktopLg' + | 'children' + | 'className' + | 'row' + | 'col' + | 'gap' + | 'offset' + export function isCustomProps( props: - | Omit< - DefaultGridProps, - | 'mobile' - | 'tablet' - | 'desktop' - | 'widescreen' - | 'mobileLg' - | 'tabletLg' - | 'desktopLg' - | 'children' - | 'className' - | 'row' - | 'col' - | 'gap' - | 'offset' - > - | Omit< - CustomGridProps, - | 'mobile' - | 'tablet' - | 'desktop' - | 'widescreen' - | 'mobileLg' - | 'tabletLg' - | 'desktopLg' - | 'children' - | 'className' - | 'row' - | 'col' - | 'gap' - | 'offset' - > -): props is CustomGridProps { + | Omit + | Omit, omittedProps> +): props is Omit, omittedProps> { return 'asCustom' in props }