2

How can I compile coffee to js without add var foo, bar, baz ? with this exemple code :

foo = 42
bar = foo + 2
baz = bar + 3

coffee -c give

alert "Hello CoffeeScript!"

var bar, baz, foo;

foo = 42;

bar = foo + 2;

baz = bar + 3;

How can I ignore variables déclarations ?

Matrix
  • 3,458
  • 6
  • 40
  • 76
  • Why do you want to do this? Do you purposely want those three variables to be global? – mu is too short Sep 26 '16 at 03:29
  • 1
    Yes, my script works if there is no "var" (I delete it at hand to test), but not works when there is declaration ;) – Matrix Sep 26 '16 at 10:31
  • @muistooshort this question (http://stackoverflow.com/questions/4214731/how-do-i-define-global-variables-in-coffeescript) don't resolved my problem... May be it's impossible to remove declaration in coffee? – Matrix Sep 27 '16 at 10:51
  • If you want to remove the `var`s then you want global variables, the duplicate covers globals. – mu is too short Sep 27 '16 at 17:52
  • it's more complicate : I can't add global.foo for foo var because the code is used on client side too, and in my case, It's forbidden to modify client code. – Matrix Sep 28 '16 at 15:58

0 Answers0