andreypopp / reactify

[DEPRECATED] Browserify transform for JSX (superset of JavaScript used in React library by Facebook)
MIT License
690 stars 68 forks source link

support for flow types #45

Closed robz closed 9 years ago

robz commented 9 years ago

When I run browserify -t reactify main.js with these files:

add.js

/* @flow */
module.exports = function (x: number, y: number) : number {
  return x + y;
};

main.js

/* @flow */
var add = require('./add');
console.log(add(3, 1));

I get this error:

module.exports = function (x: number, y: number) : number {
                            ^
ParseError: Unexpected token

The JSX transform that comes with react tools v. 0.12.2 can strip out flow type annotations from this file with jsx --strip-types (not sure if later versions do this). I'm new to NPM and node, etc. so I'm not sure how to add this transform to reactify. I tried changing the react-tools field in my project's node_modules/reactify/package.json to "~0.12.2" and then ran npm build, but it didn't seem to have any effect.

Is there a way to strip out flow types with reactify? Or do I need to run jsx in a separate command before running browserify?

robz commented 9 years ago

I figured it out from a flow example and your strip-types branch! Just need to use 0.17.0, and then I could run this: browserify -t [ reactify --strip-types ] main.js