atlassian / atlassian/extract-react-types

Add converter for TSTypeOperator

Open
#59 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
188
Forks
31
PR merge metrics
No merged PRs in 30d

Description

We have a complicated type that looks like:

```
// HtmlAttributes = AllHTMLAttributes - OnlyButtonProps
// We do this so onClick, and other props that overlap with html attributes,
// have the type defined by OnlyButtonProps.
type HtmlAttributes = Pick<
React.AllHTMLAttributes,
Exclude, keyof OnlyButtonProps>
>;

// This ends up being the Button prop API
type ButtonProps = HtmlAttributes & OnlyButtonProps
```

Running extract-react-types on this type throws the following error:

../packages/core/button/src/components/Button.tsx (../node_modules/extract-react-types-loader!../packages/core/button/src/components/Button.tsx)
Module build failed (from ../node_modules/extract-react-types-loader/index.js):
Error: Missing converter for: TSTypeOperator

It's pretty understandable something like this would not be supported by `extract-react-types`. This issue is really to discuss how type system specific features should (or shouldn't) be supported. My workaround at the moment is just creating a new file with a dummy component with the prop types I want extracted.

Maybe this highlights a need for a magic comment that `extract-react-types` will look for and extract if it exists.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.