codemix / babel-plugin-typecheck

Static and runtime type checking for JavaScript in the form of a Babel plugin.
MIT License
886 stars 44 forks source link

Type alias for object doesn't work? #107

Closed hanfeisun closed 8 years ago

hanfeisun commented 8 years ago

Here is my Javascript code:

type BasicSeq = {captureTime: number};
var k:BasicSeq = {x:1};

It works without throwing errors.

And following is my .babelrc file:

{
  "presets": ["react", "es2015"],
  "env": {
    "development": {
      "plugins": [["typecheck", {
                      "disable": {
                        "production": true
                      }
                    }],
        ["react-transform", {
          "transforms": [{
            "transform": "react-transform-hmr",
            "imports": ["react"],
            "locals": ["module"]
          }, {
            "transform": "react-transform-catch-errors",
            "imports": ["react", "redbox-react"]
          }]
        }]
      ]
    },
    "production": {
    }
  }
}

Does that mean there is no checking for type alias for object currently?

phpnode commented 8 years ago

No, this should work, sounds like a bug.

ctrlplusb commented 8 years ago

Just a quick sense check on this one, can you explicitly set the NODE_ENV=development for your command. I've read that in some environments it's not guaranteed to default to 'development'.

phpnode commented 8 years ago

node doesn't default to development, it defaults to no env set, so yes this could be related.

phpnode commented 8 years ago

Added a test for this but could not replicate in 3.7.0.