gcanti / babel-plugin-tcomb

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

Add support for Variable declarations (let) #70

Open gcanti opened 8 years ago

gcanti commented 8 years ago

Example

let bar: bool = foo;

bar = true;

compiles to

let bar = _assert(foo, _t.Boolean, "bar");

bar = _assert(true, _t.Boolean, "bar");

@christophehurpeau let me know if you want to work on this. From my part I'd love to help you out writing a test suite which I'll post later here or in a apposite branch

christophehurpeau commented 8 years ago

bar = true; should not compile to bar = _assert(true, _t.Boolean, "bar"); because we know that true is a boolean, in my opinion.

gcanti commented 8 years ago

Yeah, but seems just an optimization which btw implies a bit of (albeit basic) static analysis, I think it doesn't worth it to complicate the plugin code for this. In the end of the day asserts will be discarded in production builds

christophehurpeau commented 8 years ago

see #111

ArmorDarks commented 7 years ago

Hi!

It's slightly unclear — plugin still does not support lets?