From ea907a10b187650017fc1716303ad5488fd6f1c6 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Sun, 7 Jul 2024 04:20:33 -0700 Subject: [PATCH] feat: Add TypeScript types for , , , (#3100) * feat: add typings for and * feat: add typings for * feat: add typings for * chore: typing cleanups for code * feat: slightly more detailed types for - per review --- src/Chip/ChipIcon.tsx | 4 +-- .../__snapshots__/IconButton.test.tsx.snap | 32 ++++++++++++++++--- src/IconButton/index.tsx | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/Chip/ChipIcon.tsx b/src/Chip/ChipIcon.tsx index af487eb86f..8ef97ef1ee 100644 --- a/src/Chip/ChipIcon.tsx +++ b/src/Chip/ChipIcon.tsx @@ -7,9 +7,7 @@ import { STYLE_VARIANTS } from './constants'; export type ChipIconProps = { className: string, src: React.ComponentType, - onClick?: KeyboardEventHandler & MouseEventHandler, - alt?: string, - variant: string, + variant: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS], disabled?: boolean, } & ( // Either _both_ onClick and alt are provided, or neither is: diff --git a/src/IconButton/__snapshots__/IconButton.test.tsx.snap b/src/IconButton/__snapshots__/IconButton.test.tsx.snap index 58429cad8c..dd82977c10 100644 --- a/src/IconButton/__snapshots__/IconButton.test.tsx.snap +++ b/src/IconButton/__snapshots__/IconButton.test.tsx.snap @@ -47,11 +47,33 @@ exports[` renders with deprecated props 1`] = ` - + `; diff --git a/src/IconButton/index.tsx b/src/IconButton/index.tsx index 5e38e1b35f..601479cd0e 100644 --- a/src/IconButton/index.tsx +++ b/src/IconButton/index.tsx @@ -2,9 +2,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { type Placement } from 'react-bootstrap/Overlay'; -import Icon from '../Icon'; import { OverlayTrigger } from '../Overlay'; import Tooltip from '../Tooltip'; +import Icon from '../Icon'; interface Props extends React.HTMLAttributes { iconAs?: React.ComponentType,