Importing tcomb
gives undefined:
import t from 'tcomb';
console.log(t); // undefined
// So this won't work
t.assert(t.Number.is(colorString), 'colorString is invalid argument');
However I got it working like this, which actually I like more:
import {assert, Number} from 'tcomb';
assert(Number.is(colorString), 'colorString is invalid argument');
Importing all as t returns just the assert()
method not the full object
import * as t from 'tcomb';
I'm using a pretty standard setup with webpack-dev-server, angular 2, typescript and HMR. All libs so far load ok. The project is already a few months old.
Any idea on what is happening here? Why t
is undefined
?
Note: I'm using runtime check even if I have TS types all over the place because some services methods could still receive the wrong arguments at runtime. As a sidenote, tcomb
seems fine to me, but just to learn, is there a better option than tcomb
?