brigand / brigand/babel-plugin-flow-react-proptypes

Undefined variable in output when input file contains two classes using same prop types

Open
#215 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
427
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Example code:
```
import * as React from "react";
import type {RowProps} from "./other-row.jsx";
type StaticProps = RowProps & {
domain: string,
};
class TableOfContentsRow extends React.Component {
render() {
return

I'm a row
;
}
}
export default class TableOfContentsRowWithQuery extends React.Component {
render() {
return ;
}
}
```

Error:
```
ReferenceError: bpfrpt_proptype_RowProps is not defined
```

This error is trigged by the following code in the output:
```javascript
_defineProperty(TableOfContentsRowWithQuery, \\"propTypes\\", Object.assign({}, bpfrpt_proptype_RowProps === _propTypes.default.any ? {} : _otherRow.bpfrpt_proptype_RowProps, {
domain: _propTypes.default.string.isRequired
}));"
```

https://github.com/Khan/babel-plugin-flow-react-proptypes/commit/f43dc4087b2de43d94d3c1e05c0a267c7aed2f59 contains the test case and a snapshot with the error.

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.