Skip to content

Commit 835b464

Browse files
committed
add types to IconButton.tsx --no-verify due to Icon not migrated yet
1 parent 551ded1 commit 835b464

File tree

3 files changed

+53
-12
lines changed

3 files changed

+53
-12
lines changed

client/common/IconButton.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
1+
import React, { ComponentType } from 'react';
32
import styled from 'styled-components';
43
import Button from './Button';
54
import { remSize } from '../theme';
@@ -12,8 +11,18 @@ const ButtonWrapper = styled(Button)`
1211
}
1312
`;
1413

15-
const IconButton = (props) => {
16-
const { icon, ...otherProps } = props;
14+
type IconProps = {
15+
'aria-label'?: string
16+
};
17+
18+
type IconButtonProps = Omit<
19+
React.ComponentProps<typeof Button>,
20+
'iconBefore' | 'iconOnly' | 'display' | 'focusable'
21+
> & {
22+
icon?: ComponentType<IconProps> | null
23+
};
24+
25+
const IconButton = ({ icon = null, ...otherProps }: IconButtonProps) => {
1726
const Icon = icon;
1827

1928
return (
@@ -27,12 +36,4 @@ const IconButton = (props) => {
2736
);
2837
};
2938

30-
IconButton.propTypes = {
31-
icon: PropTypes.func
32-
};
33-
34-
IconButton.defaultProps = {
35-
icon: null
36-
};
37-
3839
export default IconButton;

package-lock.json

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"@types/react": "^16.14.0",
132132
"@types/react-dom": "^16.9.25",
133133
"@types/react-router-dom": "^5.3.3",
134+
"@types/styled-components": "^5.1.34",
134135
"@typescript-eslint/eslint-plugin": "^5.62.0",
135136
"@typescript-eslint/parser": "^5.62.0",
136137
"babel-core": "^7.0.0-bridge.0",

0 commit comments

Comments
 (0)