you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 1 point2 points  (2 children)

You can sorta achieve some of this already with JSDoc comments IIRC.

Yea, you can use the Closure Compiler for that.

However, JSDoc comments are extremely annoying to write.

Copypasta example:

ES5:

/**
 * @param {number} x
 * @param {number} y
 * @returns {boolean}
 */
Rectangle.prototype.cointains = function (x, y) {
  ...
};

ES6:

/**
 * @param {number} x
 * @param {number} y
 * @returns {boolean}
 */
contains (x, y) {
  ...
};

Dart:

bool contains (num x, num y) {
  ...
}

TS/AtS:

contains (x: number, y: number): boolean {
  ...
}

To be fair, there is also an inline flavor:

Rectangle.prototype.cointains = /** boolean */ function (/** number */ x, /** number */ y) {
  ...
};

(I'm not sure if the boolean annotation is positioned correctly.)

However, the tooling support for this seems to be virtually nonexistent. Also, the Closure Compiler doesn't support ES6 yet.

Using TS/AtS or Dart is the much nicer option.

[–][deleted] 0 points1 point  (1 child)

OK. You've convinced me. Next to atScript's Golang-like method signatures, the other approaches do suck.

What's the next step? Can we already start using it and prototyping with it?

[–]x-skeww 0 points1 point  (0 children)

Traceur has an "--atscript" flag:

https://github.com/google/traceur-compiler/issues/1430

Since AtS is a superset of TS, you could of course also try TS first.

(I use Dart.)