CoffeeScript 2 available now

New major version of JavaScript transcompiler programming language released
19 September 2017   1148

Great news for CoffeeScript fans! New major version is finally available. 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.

New major features:

  • The CoffeeScript 2 compiler now translates CoffeeScript code into modern JavaScript syntax. So a CoffeeScript => is now output as =>, a CoffeeScript class is now output using the class keyword, and so on. This means you may need to transpile the CoffeeScript compiler’s output.
  • CoffeeScript 2 adds support for async functions syntax, for the future object destructuring syntax, and for JSX. Some features, such as modules (import and export statements), for…of, and tagged template literals were backported into CoffeeScript versions 1.11 and 1.12.
  • All of the above was achieved with very few breaking changes from 1.x. Most current CoffeeScript projects should be able to upgrade with little or no refactoring necessary.

CoffeeScript 2 was developed with two primary goals: remove any incompatibilities with modern JavaScript that might prevent CoffeeScript from being used on a project; and preserve as much backward compatibility as possible.

The following CoffeeScript features were updated in 2.0 to output using modern JavaScript syntax:

  • 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()

There seem to be two breaking changes that affect a significant number of projects:

  • In CoffeeScript 2, “bare” super (calling super without arguments) is now no longer allowed, and one must use super() or super arguments... instead.
  • References to this/@ cannot occur before a call to super, per the JS spec.

CoffeeScript 2 has added support for the following:

  • JSX
  • Line comments are now output (in CoffeeScript 1 they were discarded)
  • Block comments are now allowed anywhere, enabling static type annotations using Flow’s comment-based syntax

Learn more at official website.  

AngularJS to Angular Migration Tools to be Released

New tools are called ngMigration Assistant and ngMigration Forum
17 August 2018   207

The JS-development team AngularJS has released two customers' "helper" - ngMigration Assistant and Forum. The tools show which migration from AngularJS to Angular is correct, how to simplify the process as much as possible and avoid mistakes.

ngMigration Assistant is a command-line tool that analyzes any AngularJS application, regardless of size, and recommends an optimal migration path. It provides statistics on the complexity, size, and patterns of an app. Based on this data, the program offers a list of clear recommendations that simplify the transition from AngularJS to Angular, taking into account the size and complexity of the code.

You can find an example of using the ngMigration Assistant for the AngularJS phone catalog application below. Using the ngma command, registered in the directory, analysis is performed and recommendations are written.

Displaying ngMigration Assitant statistics
Displaying ngMigration Assitant statistics

Initially, the tool shows statistics of the available data, and after - the stages of preparation for migration to Angular.

NgMigration Assitant Recommendations
NgMigration Assitant Recommendations

The new ngMigration Forum collects up-to-date information on migration paths and tools that provide the transition from AngularJS to Angular. ngMigration Forum is a place for sharing experiences, solving problems and asking questions.

The last update of Angular 6.1 was released in late July 2018. In Angular, support for TypeScript 2.8 and 2.9 was added, as well as the ability to configure the router to store and restore the scrolling position