Repository: brigand/babel-plugin-flow-react-proptypes (js)

Issue:
PropTypes are not added to class components with intersected type parameters
For example, no propTypes will be assigned to this class:

```jsx
var React = require('react');

type FooProps = {
  a_number: number
}

export default class Foo extends React.Component<FooProps & {
  b_number: number
}> {
}
```

Instead, the snippet above just gets translated into something like this:

```jsx
var React = require('react');

let Foo = class Foo extends React.Component {};
export { Foo as default };
```

Pull request:
Support class components with intersection type annotations
This resolves #193 

Patch:
diff --git a/src/index.js b/src/index.js
index f4391f5..a2e8e29 100644
--- a/src/index.js
+++ b/src/index.js
@@ -502,7 +502,7 @@ module.exports = function flowReactPropTypes(babel) {
           propTypes = props;
         }
 
-        if (secondSuperParam && secondSuperParam.type === 'ObjectTypeAnnotation') {
+        if (secondSuperParam && (secondSuperParam.type === 'ObjectTypeAnnotation' || secondSuperParam.type === 'IntersectionTypeAnnotation')) {
           propTypes = convertToPropTypes(secondSuperParam, importedTypes, internalTypes);
         }
 


Test patch:
diff --git a/src/__tests__/__snapshots__/class-intersection-type-parameter-test.js.snap b/src/__tests__/__snapshots__/class-intersection-type-parameter-test.js.snap
new file mode 100644
index 0000000..1aba922
--- /dev/null
+++ b/src/__tests__/__snapshots__/class-intersection-type-parameter-test.js.snap
@@ -0,0 +1,41 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`class-intersection-type-parameter-test 1`] = `
+"'use strict';
+
+Object.defineProperty(exports, \\"__esModule\\", {
+  value: true
+});
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = _interopRequireDefault(_propTypes);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\\"Cannot call a class as a function\\"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\\"this hasn't been initialised - super() hasn't been called\\"); } return call && (typeof call === \\"object\\" || typeof call === \\"function\\") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== \\"function\\" && superClass !== null) { throw new TypeError(\\"Super expression must either be null or a function, not \\" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var React = require('react');
+
+var Foo = function (_React$Component) {
+  _inherits(Foo, _React$Component);
+
+  function Foo() {
+    _classCallCheck(this, Foo);
+
+    return _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).apply(this, arguments));
+  }
+
+  return Foo;
+}(React.Component);
+
+Foo.propTypes = {
+  a_number: _propTypes2.default.number.isRequired,
+  b_number: _propTypes2.default.number.isRequired
+};
+exports.default = Foo;"
+`;
diff --git a/src/__tests__/class-intersection-type-parameter-test.js b/src/__tests__/class-intersection-type-parameter-test.js
new file mode 100644
index 0000000..c346adc
--- /dev/null
+++ b/src/__tests__/class-intersection-type-parameter-test.js
@@ -0,0 +1,22 @@
+const babel = require('babel-core');
+const content = `
+var React = require('react');
+
+type FooProps = {
+  a_number: number
+}
+
+export default class Foo extends React.Component<FooProps & {
+  b_number: number
+}> {
+}
+`;
+
+it('class-intersection-type-parameter-test', () => {
+  const res = babel.transform(content, {
+    babelrc: false,
+    presets: ['es2015', 'stage-1', 'react'],
+    plugins: ['syntax-flow', require('../')],
+  }).code;
+  expect(res).toMatchSnapshot();
+});