Tuesday, 25 April 2017

Type hints of flow not stripped by babel

I have React.JS project. The project uses custom 'theme' with UI components. Build scripts (webpack config, babel configs, etc.) provided with this 'theme'.

I want to start use flow type checker in this project. I installed needed npm packages and added flow to babel's presets. Then I added props = {mytestprop: string} to one of my React`s classes.

Webpack compiled my code successfully but type hints not stripped!!! Of course browser not able to execute this code - it raises ReferenceError: string is not defined.

List of presets from .babelrc: ["es2015", "react", "stage-2", "flow"]. I'm sure that this is actual list used by babel because if I delete any of the first 3 presets - compilation failed.

Do you have any ideas what can lead to such behaviour of stripper of flow types?



via Victor Mezrin

No comments:

Post a Comment