Skip to content

Commit

Permalink
🐛 fix Icon component ts error with cra definition
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Dec 9, 2019
1 parent 0b1a540 commit 85fcf0f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
'!components/*/style/index.tsx',
'!components/style/index.tsx',
'!components/*/locale/index.tsx',
'!components/form/__tests__/type.test.tsx',
'!components/*/__tests__/type.test.tsx',
'!components/**/*/interface.{ts,tsx}',
],
transformIgnorePatterns,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions components/icon/__tests__/type.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable */
import React from 'react';
import Icon from '..';
import { ReactComponent as logo } from './logo.svg';

describe('Icon TypeScript test', () => {
it('empty test case placeholder to avoid jest error', () => {
// empty
});
});

<Icon component={logo} />;
2 changes: 1 addition & 1 deletion components/icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface IconProps {
title?: string;
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
onClick?: React.MouseEventHandler<HTMLElement>;
component?: React.ComponentType<CustomIconComponentProps>;
component?: React.ComponentType<CustomIconComponentProps | React.SVGProps<SVGSVGElement>>;
twoToneColor?: string;
viewBox?: string;
spin?: boolean;
Expand Down
10 changes: 9 additions & 1 deletion typings/custom-typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
declare module '*.svg';
// https://github.com/facebook/create-react-app/blob/f09d3d3a52c1b938cecc977c2bbc0942ea0a7e70/packages/react-scripts/lib/react-app.d.ts#L42-L49
declare module '*.svg' {
import * as React from 'react';

export const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;

const src: string;
export default src;
}

declare module 'rc-calendar*';

Expand Down

0 comments on commit 85fcf0f

Please sign in to comment.