Skip to content

Commit 82154c3

Browse files
committed
Support React.FC in Typescript
1 parent 62e692f commit 82154c3

13 files changed

+2315
-264
lines changed

Diff for: .changeset/cyan-ways-fry.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
'react-docgen': major
3+
---
4+
5+
`getTypeFromReactComponent` now returns an array of paths to types instead of
6+
just one. This can appear when multiple type definitions are found for a
7+
component, for example:
8+
9+
```ts
10+
const Component: React.FC<Props> = (props: { some: string }) => {};
11+
```
12+
13+
In this example both the `Props` definition as well as `{ some: string }` are
14+
now found and used.
15+
16+
Here is a simple diff to illustrate the change when using
17+
`getTypeFromReactComponent`:
18+
19+
```diff
20+
21+
const type = getTypeFromReactComponent(path)
22+
23+
-if (type) {
24+
+if (type.length > 0) {
25+
// do smth
26+
}
27+
28+
```

Diff for: .changeset/sour-jeans-tell.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-docgen': minor
3+
---
4+
5+
Add support for React.FC in TypeScript

0 commit comments

Comments
 (0)