Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the one think that TypeScript needs to get it going is modularity. If another project like [harp](https://github.com/sintaxi/harp) could use TypeScript as a library and could compile the code without having to result to system commands would be a great thing.

However, I think if someone came up with a system to add optional typing through the use of string literals it would be awesome. That way we can have perfectly valid JavaScript with the benefits of certain JavaScript engines and type checkers. The string literal would be before a function declaration like:

    "add(Number, Number) -> Number";
    var add = function(x, y) { return x + y; };
That would basically specify that the function takes two numbers, and returns a number. This system would not replace a language like TypeScript, as TypeScript provides much more functionality. But it would allow for really simple optional typing and for TypeScript to take advantage of this(in the case that a JavaScript engine eventually implements and optimizes for these type declarations).


The TypeScript compiler can be used as a library, I believe.

The Closure Compiler has a whole type system that lives in doc comments:

https://developers.google.com/closure/compiler/docs/js-for-c...

and I believe there's a command line option for doing type checking. Alas, Closure Compiler is written in Java rather than JavaScript so you can't use it quite as seamlessly as TypeScript's compiler.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: