Skip to content

Commit 7ae9cc6

Browse files
committed
add test for React.ComponentPropsWithoutRef<Props>
Signed-off-by: Winner95 <Winner95@users.noreply.github.com>
1 parent 707ac00 commit 7ae9cc6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

__tests__/handler.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ describe('typescript-react-function-component-props-handler', () => {
9494
expect(doc.props.as.tsType.name).toBe("T");
9595
});
9696

97+
test('handles React.ComponentPropsWithoutRef<Props>', () => {
98+
const doc = parseFixture('PrimaryButtonPropsFromPackage.tsx');
99+
100+
expect(doc.props).toBeUndefined();
101+
});
102+
97103
// Line 31 in index.js without type - can't be tested directly because of early return
98104
test('handles components without type', () => {
99105
const doc = parseFixture('ComponentWithoutType.tsx');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
const PrimaryButtonPrimitive = (props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => {
4+
return (<div {...props} />);
5+
};
6+
7+
type PrimaryButtonPropsFromPackage = React.ComponentPropsWithoutRef<
8+
typeof PrimaryButtonPrimitive
9+
>;
10+
11+
export const PrimaryButton: React.FC<PrimaryButtonPropsFromPackage> = (
12+
props
13+
) => <PrimaryButtonPrimitive {...props} />;

0 commit comments

Comments
 (0)