From e595b9a42fc594bd2d4fee24900ed92f485ef563 Mon Sep 17 00:00:00 2001 From: Mike Perrotti Date: Tue, 27 Jun 2023 18:04:15 -0400 Subject: [PATCH 01/13] fixes type errors that appeared during v36 updates --- src/CounterLabel/CounterLabel.tsx | 1 - src/Token/TokenBase.tsx | 35 +++++++++++++++------------- src/drafts/MarkdownEditor/Footer.tsx | 5 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/CounterLabel/CounterLabel.tsx b/src/CounterLabel/CounterLabel.tsx index 7de16f4405a..7871e2c24a5 100644 --- a/src/CounterLabel/CounterLabel.tsx +++ b/src/CounterLabel/CounterLabel.tsx @@ -34,7 +34,6 @@ const CounterLabel = forwardRef( )} {...props} as="span" - // @ts-expect-error Box is expecting a divelement, but this component forces a span element ref={forwardedRef} > {children} diff --git a/src/Token/TokenBase.tsx b/src/Token/TokenBase.tsx index 366a51edc04..a0ae3688b43 100644 --- a/src/Token/TokenBase.tsx +++ b/src/Token/TokenBase.tsx @@ -128,22 +128,25 @@ const StyledTokenBase = styled.span< ${sx} ` -const TokenBase = React.forwardRef(({onRemove, onKeyDown, id, size = defaultTokenSize, ...rest}, forwardedRef) => { - return ( - ) => { - onKeyDown && onKeyDown(event) +const TokenBase = React.forwardRef( + ({onRemove, onKeyDown, id, size = defaultTokenSize, ...rest}, forwardedRef) => { + return ( + ) => { + onKeyDown && onKeyDown(event) - if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) { - onRemove() - } - }} - id={id?.toString()} - size={size} - {...rest} - ref={forwardedRef} - /> - ) -}) as PolymorphicForwardRefComponent<'span' | 'a' | 'button', TokenBaseProps & SxProp> + if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) { + onRemove() + } + }} + id={id?.toString()} + size={size} + {...rest} + // @ts-expect-error TokenBase wants Anchor, Button, and Span refs + ref={forwardedRef} + /> + ) + }, +) as PolymorphicForwardRefComponent<'span' | 'a' | 'button', TokenBaseProps & SxProp> export default TokenBase diff --git a/src/drafts/MarkdownEditor/Footer.tsx b/src/drafts/MarkdownEditor/Footer.tsx index 3b23623c843..230c58b37c4 100644 --- a/src/drafts/MarkdownEditor/Footer.tsx +++ b/src/drafts/MarkdownEditor/Footer.tsx @@ -1,7 +1,8 @@ import React, {memo, forwardRef, useContext} from 'react' import {AlertIcon, ImageIcon, MarkdownIcon} from '@primer/octicons-react' -import {Spinner, Button, ButtonProps, LinkButton, Box, Text} from '../..' +import {Spinner, LinkButton, Box, Text} from '../..' +import {Button, ButtonProps} from '../Button2' import {MarkdownEditorContext} from './_MarkdownEditorContext' import {useSlots} from '../../hooks/useSlots' @@ -80,7 +81,7 @@ const FileUploadButton = memo(({fileDraggedOver, ...props}: Partial return (