Skip to content

Commit 77095c9

Browse files
committed
add cover for React children component props
Signed-off-by: Winner95 <Winner95@users.noreply.github.com>
1 parent 84292f6 commit 77095c9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

__tests__/handler.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ describe('typescript-react-function-component-props-handler', () => {
122122
);
123123
});
124124

125+
test('handles React.FC<Props> components with interface props', () => {
126+
const doc = parseFixture('Stack.tsx');
127+
128+
expect(doc).toHaveProperty('props');
129+
expect(doc.props).toHaveProperty('children');
130+
expect(doc.props.children.tsType).toMatchObject({ name: 'ReactReactNode' });
131+
expect(doc.props.children.tsType.raw).toBe('React.ReactNode');
132+
});
133+
125134
// Line 31 in index.js without type - can't be tested directly because of early return
126135
test('handles components without type', () => {
127136
const doc = parseFixture('ComponentWithoutType.tsx');

fixtures/Stack.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
interface StackProps {
4+
alignItems?: 'flex-start' | 'center' | 'flex-end';
5+
justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between';
6+
gap?: 'xs' | 's' | 'm' | 'l';
7+
children?: React.ReactNode;
8+
}
9+
10+
export const Stack: React.FC<StackProps> = (props) => {
11+
return <>{props.children}</>;
12+
};

0 commit comments

Comments
 (0)