CoffeeScript 2.0 Released

CoffeeScript

CoffeeScript just made v2.0 available and there’s a lot included in this release that has been in development since the beginning of 2017. I think the best way to sum of the changes is the following from the announcement:

This new release of the CoffeeScript language and compiler aims to bring CoffeeScript into the modern JavaScript era, closing gaps in compatibility with JavaScript while preserving the clean syntax that is CoffeeScript’s hallmark.

I think support for the following is a nice addition, especially since most devs have been using them for a while now in vanilla JS:

  • Modules: import/export
  • Classes: class Animal
  • Async functions: await someFunction()
  • Bound/arrow functions: =>
  • Function default parameters: (options = {}) ->
  • Function splat/rest parameters: (items...) ->
  • Destructuring, for both arrays and objects: [first, second] = items{length} = items
  • Object rest/spread properties: {options..., force: yes}{force, otherOptions...} = options
  • Interpolated strings/template literals (JS backticked strings): "Hello, #{user}!"
  • Tagged template literals: html"<strong>coffee</strong>"
  • JavaScript’s for…of is now available as CoffeeScript’s for…from (we already had a for…of): for n from generatorFunction()

Release notes can be found here and the official release on GitHub can be found here.