Skip to content

Commit 85fcf0f

Browse files
committed
🐛 fix Icon component ts error with cra definition
close ant-design#13205 close ant-design#19638
1 parent 0b1a540 commit 85fcf0f

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

.jest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
'!components/*/style/index.tsx',
3232
'!components/style/index.tsx',
3333
'!components/*/locale/index.tsx',
34-
'!components/form/__tests__/type.test.tsx',
34+
'!components/*/__tests__/type.test.tsx',
3535
'!components/**/*/interface.{ts,tsx}',
3636
],
3737
transformIgnorePatterns,

components/icon/__tests__/logo.svg

Loading
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
import React from 'react';
3+
import Icon from '..';
4+
import { ReactComponent as logo } from './logo.svg';
5+
6+
describe('Icon TypeScript test', () => {
7+
it('empty test case placeholder to avoid jest error', () => {
8+
// empty
9+
});
10+
});
11+
12+
<Icon component={logo} />;

components/icon/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface IconProps {
6767
title?: string;
6868
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
6969
onClick?: React.MouseEventHandler<HTMLElement>;
70-
component?: React.ComponentType<CustomIconComponentProps>;
70+
component?: React.ComponentType<CustomIconComponentProps | React.SVGProps<SVGSVGElement>>;
7171
twoToneColor?: string;
7272
viewBox?: string;
7373
spin?: boolean;

typings/custom-typings.d.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
declare module '*.svg';
1+
// https://github.com/facebook/create-react-app/blob/f09d3d3a52c1b938cecc977c2bbc0942ea0a7e70/packages/react-scripts/lib/react-app.d.ts#L42-L49
2+
declare module '*.svg' {
3+
import * as React from 'react';
4+
5+
export const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
6+
7+
const src: string;
8+
export default src;
9+
}
210

311
declare module 'rc-calendar*';
412

0 commit comments

Comments
 (0)