gcanti / babel-plugin-tcomb

Babel plugin for static and runtime type checking using Flow and tcomb
MIT License
482 stars 22 forks source link

Using only in dev mode #133

Closed jefffriesen closed 8 years ago

jefffriesen commented 8 years ago

A couple issues:

  1. In the readme, there is a note below the .babelrc setup that says how to use this only in dev mode. Why wouldn't this be the default setup in the documentation? Do people typically use this in production?
  2. I can't actually get it to actually work in dev mode. This .babelrc doesn't work (doesn't catch type errors):
{
  "presets": ["react", "es2015", "stage-1"],
  "plugins": [
    "transform-decorators-legacy"
  ],
  "env": {
    "dev": {
      "plugins": [
        "tcomb"
      ]
    }
  }
}

This .babelrc works (catches type errors):

{
  "presets": ["react", "es2015", "stage-1"],
  "plugins": [
    "transform-decorators-legacy",
    "tcomb"
  ]
}

I've confirmed that the environment is set as development by console.log'ing out process.env.NODE_ENV in each case.

Have I set it up incorrectly or is this a bug? Is this typically only used in development?

Thanks

ctrlplusb commented 8 years ago

Try

{
  "presets": ["react", "es2015", "stage-1"],
  "plugins": [
    "transform-decorators-legacy"
  ],
  "env": {
    "development": {
      "plugins": [
        "tcomb"
      ]
    }
  }
}

Note the dev -> development. i.e. it needs to match the value of your NODE_ENV.

jefffriesen commented 8 years ago

Hey - that works. When you wrote that it was obvious. I don't know why I was using 'dev'. I must have seen other env examples using 'dev'.

Any thoughts on documenting tcomb as dev-only by default? I can submit a documentation PR.