babel-plugin-tcomb icon indicating copy to clipboard operation
babel-plugin-tcomb copied to clipboard

Add support for Variable declarations (let)

Open gcanti opened this issue 9 years ago • 4 comments

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

gcanti avatar Jul 18 '16 09:07 gcanti

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

christophehurpeau avatar Jul 18 '16 09:07 christophehurpeau

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

gcanti avatar Jul 18 '16 09:07 gcanti

see #111

christophehurpeau avatar Sep 09 '16 19:09 christophehurpeau

Hi!

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

ArmorDarks avatar Feb 23 '17 07:02 ArmorDarks