diff --git a/src/Chip/Chip.test.jsx b/src/Chip/Chip.test.tsx similarity index 94% rename from src/Chip/Chip.test.jsx rename to src/Chip/Chip.test.tsx index f5e5367d18..1624e62d36 100644 --- a/src/Chip/Chip.test.jsx +++ b/src/Chip/Chip.test.tsx @@ -7,7 +7,7 @@ import { Close } from '../../icons'; import { STYLE_VARIANTS } from './constants'; import Chip from '.'; -function TestChip(props) { +function TestChip(props: Omit, 'children'>) { return ( Test @@ -42,15 +42,13 @@ describe('', () => { iconBeforeAlt="close icon" iconAfter={Close} iconAfterAlt="close icon" - > - Chip - + /> )).toJSON(); expect(tree).toMatchSnapshot(); }); it('renders div with "button" role when onClick is provided', () => { const tree = renderer.create(( - Chip + )).toJSON(); expect(tree).toMatchSnapshot(); }); @@ -104,7 +102,7 @@ describe('', () => { />, ); const iconAfter = screen.getByLabelText('icon-after'); - await userEvent.click(iconAfter, '{enter}', { skipClick: true }); + await userEvent.click(iconAfter); expect(func).toHaveBeenCalledTimes(1); }); it('onIconBeforeClick is triggered', async () => { @@ -130,7 +128,7 @@ describe('', () => { />, ); const iconBefore = screen.getByLabelText('icon-before'); - await userEvent.click(iconBefore, '{enter}', { skipClick: true }); + await userEvent.click(iconBefore); expect(func).toHaveBeenCalledTimes(1); }); it('checks the absence of the `selected` class in the chip', async () => { diff --git a/src/Chip/ChipIcon.tsx b/src/Chip/ChipIcon.tsx index 266f2ad7ad..527cf54422 100644 --- a/src/Chip/ChipIcon.tsx +++ b/src/Chip/ChipIcon.tsx @@ -1,19 +1,19 @@ import React, { KeyboardEventHandler, MouseEventHandler } from 'react'; import PropTypes from 'prop-types'; import Icon from '../Icon'; -// @ts-ignore import IconButton from '../IconButton'; -// @ts-ignore import { STYLE_VARIANTS } from './constants'; -export interface ChipIconProps { +export type ChipIconProps = { className: string, src: React.ComponentType, - onClick?: KeyboardEventHandler & MouseEventHandler, - alt: string, variant: string, disabled?: boolean, -} +} & ( + // Either _both_ onClick and alt are provided, or neither is: + | { onClick: KeyboardEventHandler & MouseEventHandler, alt: string } + | { onClick?: undefined, alt?: undefined } +); function ChipIcon({ className, src, onClick, alt, variant, disabled, diff --git a/src/Chip/__snapshots__/Chip.test.jsx.snap b/src/Chip/__snapshots__/Chip.test.tsx.snap similarity index 100% rename from src/Chip/__snapshots__/Chip.test.jsx.snap rename to src/Chip/__snapshots__/Chip.test.tsx.snap diff --git a/src/Chip/constants.js b/src/Chip/constants.ts similarity index 91% rename from src/Chip/constants.js rename to src/Chip/constants.ts index 6259d0c8dd..dea354757b 100644 --- a/src/Chip/constants.js +++ b/src/Chip/constants.ts @@ -2,4 +2,4 @@ export const STYLE_VARIANTS = { DARK: 'dark', LIGHT: 'light', -}; +} as const; diff --git a/src/Chip/index.tsx b/src/Chip/index.tsx index 0f78ab2059..ca2ef97096 100644 --- a/src/Chip/index.tsx +++ b/src/Chip/index.tsx @@ -3,9 +3,7 @@ import PropTypes, { type Requireable } from 'prop-types'; import classNames from 'classnames'; // @ts-ignore import { requiredWhen } from '../utils/propTypes'; -// @ts-ignore import { STYLE_VARIANTS } from './constants'; -// @ts-ignore import ChipIcon from './ChipIcon'; export const CHIP_PGN_CLASS = 'pgn__chip'; diff --git a/src/ChipCarousel/index.tsx b/src/ChipCarousel/index.tsx index acb26ae115..062a21a347 100644 --- a/src/ChipCarousel/index.tsx +++ b/src/ChipCarousel/index.tsx @@ -4,9 +4,7 @@ import { useIntl } from 'react-intl'; import classNames from 'classnames'; // @ts-ignore import { OverflowScroll, OverflowScrollContext } from '../OverflowScroll'; -// @ts-ignore import IconButton from '../IconButton'; -// @ts-ignore import Icon from '../Icon'; // @ts-ignore import { ArrowForward, ArrowBack } from '../../icons';