codemix / codemix/babel-plugin-typecheck

#125 introduce bug with decorators

Open
#130 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
880
Forks
44
PR merge metrics
No merged PRs in 30d

Description

``` jsx
function foobar(DecoratedComponent) {
return class Parent extends Component {

state = { isActive: true }

render() {
const { isActive } = this.state;
return ;
}

}
}

@foobar()
class Child {
props: { isActive: boolean; };

render() {
....
}
}
```

In this case, `propTypes` will be applied to `Wrapper` instead of `Parent` it will log in dev-console:

```
Warning: Failed propType: Invalid prop `isActive` supplied to `Parent`.

Expected:
bool

Got:
void
```

My .babelrc for help:

```
{
"presets": ["save"],
"plugins": [],
"env": {
"browser": {
"plugins": [
"typecheck",
["react-transform", {
"transforms": [
{
"transform": "react-transform-hmr",
"imports": [ "react" ],
"locals": [ "module" ]
},
{
"transform": "react-transform-catch-errors",
"imports": [ "react", "redbox-react" ]
}
]
}]
]
},
"production": {
"plugins": ["react-remove-prop-types"]
}
}
}
```

My workaround for now, which is painful is to call the decorator as a function in the export.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.