ckknight/gorillascript

Option to Output Type Annotations for Google Closure Compiler

Opened this issue · 0 comments

I think it would be lovely if gorillascript (optionally) output its type annotations in comments formatted for the Google Closure Compiler. Users could then use the GCC to perform static type checking on their code.

So

let increment(x as Number) x + 1

would compile to something like

/**
 * @param {number} x
 */
function increment(x) {
    if (typeof x !== "number") {
        throw new TypeError("Expected x to be a Number, got " + __typeof(x));
    }
        return x + 1;
}