brigand / brigand/babel-plugin-flow-react-proptypes
Feature: Interface support
- Dominant language
- JavaScript
- Stars
- 427
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
Hi.
What is the state state of affairs with the support of interface types?
It seems like that as of now, those do not get `bpfrpt_proptype_${name}` propType validators.
I can imagine that the full support mightn't be possible in a sensible complexity level (combination of indexers and methods *), however we could handle them essentially as object types...
```js
interface Pager {
goPrev(stepSize?: number): void,
goNext(stepSize?: number): void,
goto(number): void,
hasNext(): boolean,
hasPrev(): boolean,
}
```
would become:
```js
// import PT from 'prop-types';
PT.shape({
goPrev: PT.func.isRequired,
goNext: PT.func.isRequired,
goto: PT.func.isRequired,
hasNext: PT.bool.isRequired,
hasPrev: PT.bool.isRequired,
})
```
## * indexers + properties
It actually is kind of possible to create a prop-type validator using `prop-types`, but it's pretty kinky. You'd essentially combine `objectOf(...allPossibleTypesIncludingExplicit)` & `shape({ ...explicitAttributes })` or we could write a custom utility to check those (I wouldn't bother with multi-indexer ones)
Contributor guide
Research direction
No files or tests are named. Start by examining how the plugin currently generates PropTypes for Flow object types, then compare that behavior with the Pager interface example. Done should include generated validators for interface methods and a documented decision for indexers and properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100