Basically provide a library that contains all the possible primitive types that can be checked and functions for composing higher order types.
Then in the code do something like so:
var types = require('types');
function foo(bar, baz) {
var qux = '';
/* do something */
return qux;
}
foo.types = {
args: [types.Array, types.Object],
return: [ types.String ] // array to support ES6 destructuring assignment
}
This interface makes it trivially easy to define the types, parse the types, strip the types out on minification, etc.This approach also makes it trivially easy to compose higher order types in a separate modules and require them.
my-geometry-types.js:
var types = require('types');
var point = [types.Float, types.Float];
module.exports.point = point;
module.exports.rectangle = [point, point];
Then in another file, you can require these type modules and use them to set the type signature of a function;Anyways, my point is that building a tool like this is awesome, but a null contribution if it requires me to throw out all my existing tooling, especially for something that could have been implemented in a way that is composable. It may even be a net negative contribution if it gets traction and causes an unnecessary schism (e.g. JSX) in the community that reduces code sharing, interop and the ability for developers to stand on each others shoulders.
The beauty and strength of the NodeJS ecosystem is not the language it is based on (JavaScript) or its runtime (v8/libuv), but that it nailed a lot of details related to common conventions among developers and allowing modules to remain small and composable.
The modules created by people like prominent module contributors like Substack, Raynos, Izs and Dominic Tarr are usually stellar examples of publishing small, reusable module components. All of these guys have hundreds of small modules published that are very composable, easy test and easy/fast to replace if they don't meet your needs.
The tooling behind AtScript would be a huge contribution if it were made in a way where the components that make up the tooling could be mixed and matched for use in novel ways.