Civet: The CoffeeScript of TypeScript
github.com
github.com
As always pragmatism won and ES6 thrived, but Coffeescript still had a few things that ES6 didn't have. My favourite feature is "everything is an expression" so you can do something like this:
eldest = if 24 > 21 then "Liz" else "Ike"
see: http://coffeescript.org/#expressions
this comes from Lisp and makes a lot of things easier. Obviously this was not implemented in ES6 because it would break compatibility and there is also some problems with implicit returns that made the feature a bit weird
I wonder if a syntax like this for JS would work:
const eldest = if (24>41) { escape "Liz" } else { escape "Ike" }
with "escape" working like a mix of "break" and "return". But even then this is likely to cause incompatibilities
const eldest = 24>41 ? "Liz" : "Ike";
They’re about the same for a one-liner but if you have anything more complex, Ruby style trailing if is far superior.
For short statements like the examples given here, it's not ugly and it's easy to read. Whether it's easier/harder to read than trailing if depends on how familiar you are with each syntax. I don't think either is superior in this example.
I agree ternaries are not suitable for long complex statements.
However, I don't think trailing if is suitable for long complex statements either. I've generally only seen it used in simple cases.
Basically if I can get a reimagined successor to CoffeeScript making decisions based E20xx as it is today then I'd be quite happy.
This is an interesting design decision. Why don’t you want to combine them?
I assume this project is here for older Coffeescript [1] projects who want to start using typescript, and need access to interfaces/types that were present in old CS files.