Static typing? #1852

ghost opened this Issue Nov 10, 2011 · 11 comments


None yet

9 participants

ghost commented Nov 10, 2011

Would it be a good idea to introduce static typing in CS?


string greet = (Coder me, number|string age, string name) -> "Hi. I am a #{me.getTitle()}. My name is #{name} and I am #{age} years old"

This could solve some issues we have with JS:

  • Provide a way for IDEs to autocomplete. So when I type "me." it will give me all the instance methods for Coder. This is impossible atm.
  • Good for documentation and clean code.
  • No need for manual checking code.
  • Less bugs.



Found this one that seems to be very popular:

Any thoughts on implementing it into the core of CS?


Obviously, static typing cannot be done, because javascript is a dynamic language. is an implementation of design-by-contract and its predicates are checked in runtime.

There were some issues in coffee-script bugtracker and they was closed (#52, #116, #1833).

1 year-after edit: sorry folks, I knew a little about typing at this point. Yes it’s possible to make typed coffee.


What Paul said. Type-checking is way beyond the intended scope of CoffeeScript. If you want a statically-typed language that compiles to JS, look at or Google Dart.

steida commented Sep 13, 2012 uses Google Closure with CoffeeScript syntax, so static typing with compilation is possible.

dimack commented Oct 24, 2012

Obviously, static typing cannot be done, because javascript is a dynamic language


Soviut commented Oct 24, 2012

Later versions of ECMAScript have optional typing using the i:int format, ActionScript and UnityScript are two derivations that use it. However, CoffeeScript is a pre-processor, not a Javascript compiler! So while it could accept the typing syntax that later ECMAScript versions support, it wouldn't in any way enforce this static typing. It validates its own syntax and converts it to JavaScript, it doesn't prevent you from writing bad code!

olanod commented Jul 15, 2013

is it completely discarded? it would be a great option if CS could compile to something like asm.js or JS with closure annotations.


There's been discussions about this already. We don't have more informations than JS JITs

steida commented Jul 15, 2013

If Michael Ficarra ever finish CoffeeScript Redux, I will use it for EsteScript. CoffeeScript with type annotations for Google Closure Compiler. But annotations based static typing is good enough for now.


Ive did a workaround for this particular usecase, reusing typescript's static typing via external d.ts files, which are merged into the source during compilation.

Its called CompiledCoffee. Enjoy.

@vendethiel vendethiel added the wontfix label Nov 3, 2014

Have you folks seen TypedCoffeeScript by @TobiaszCudnik?


(Maybe?) there's also the possibility of using Flow with CoffeeScript?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment