Skip to content

Commit e55e42b

Browse files
committed
add test coverage for any type
Signed-off-by: Winner95 <Winner95@users.noreply.github.com>
1 parent f42e887 commit e55e42b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

__tests__/handler.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ describe('typescript-react-function-component-props-handler', () => {
7878
expect(doc.props.displaySettings.tsType.signature.properties).toHaveLength(3);
7979
});
8080

81+
test('handles React.FC<Props> components with type prop type of any', () => {
82+
const doc = parseFixture('LocalizedTextInput.tsx');
83+
84+
expect(doc).toHaveProperty('props');
85+
expect(doc.props).toHaveProperty('value');
86+
expect(doc.props.value.tsType.name).toBe("any");
87+
});
88+
8189
// Line 31 in index.js without type - can't be tested directly because of early return
8290
test('handles components without type', () => {
8391
const doc = parseFixture('ComponentWithoutType.tsx');

fixtures/LocalizedTextInput.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { TextInputProps } from './Types';
3+
4+
type LocalizedString = Record<string, string>;
5+
6+
type LocalizedInputBaseProps<Value extends LocalizedString = LocalizedString> =
7+
{
8+
value: any;
9+
onChange: (value: Value) => void;
10+
/** Optional selectedLanguage */
11+
selectedLanguage?: string;
12+
defaultExpandLanguages?: boolean;
13+
};
14+
15+
type LocalizedTextInputProps<Value extends LocalizedString = LocalizedString> =
16+
LocalizedInputBaseProps<Value> & Omit<TextInputProps, 'value' | 'onChange'>;
17+
18+
export const LocalizedTextInput: React.FC<LocalizedTextInputProps> = ({
19+
value,
20+
}) => {
21+
return <input value={value} />;
22+
};

0 commit comments

Comments
 (0)