Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to mix TypeScript and CoffeeScript?

I've just started to explore new JavaScript ideas and I'm pretty impressed. At first sight both CoffeeScript and TypeScript have some great features. They're both compiled to JavaScript. CoffeeScript is great because it makes code shorter and clearer. TypeScript on the other hand gives us possibility to build complex applications.

Is it possible to mix TypeScript and CoffeeScript? I mean - take advantage of both of them in the same file?

like image 841
Arkadiusz Kałkus Avatar asked Oct 26 '15 11:10

Arkadiusz Kałkus


1 Answers

Short answer: no.

You need to compile a CoffeeScript/TypeScript file to a JavaScript file, which means that this file, as a whole, must be syntactically correct for the given language.

CoffeeScript and TypeScript are not syntactically-interchangeable. At best, you would have to resort to some lowest common denominator in terms of syntax use, but that would completely defeat the purpose of using any of the two instead of plain JavaScript.

like image 87
Robert Rossmann Avatar answered Sep 20 '22 20:09

Robert Rossmann