Questions tagged [traceur]

Traceur is a JavaScript next-to-JavaScript-of-today compiler that allows you to use features from the future today.

github: google/traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler that allows you to use features from the future today. Traceur's goal is to inform the design of new JavaScript features which are only valuable if they allow you to write better code. Traceur allows you to try out new and proposed language features today, helping you say what you mean in your code while informing the standards process.

103 questions
173
votes
4 answers

Get the class name of ES6 class instance

Are there any 'harmonious' ways to get the class name from ES6 class instance? Other than someClassInstance.constructor.name Currently I'm counting on Traceur implementation. And it seems that Babel has a polyfill for Function.name while Traceur…
Estus Flask
  • 150,909
  • 47
  • 291
  • 441
145
votes
9 answers

How to implement private method in ES6 class with Traceur

I use Traceur Compiler to have advantage with ES6 features now. I want to implement this stuff from ES5: function Animal() { var self = this, sayHi; sayHi = function() { self.hi(); }; this.hi = function() {/* ...…
Glen Swift
  • 10,962
  • 14
  • 43
  • 73
68
votes
3 answers

Nested ES6 classes?

It seems possible to nest a class in a constructor which can then be instantiated from anywhere within the class, is this official? [EDIT] E.g., class C { constructor() { class D { constructor() { } } } …
user5321531
  • 2,545
  • 5
  • 21
  • 27
65
votes
7 answers

ECMAScript 6: what is WeakSet for?

The WeakSet is supposed to store elements by weak reference. That is, if an object is not referenced by anything else, it should be cleaned from the WeakSet. I have written the following test: var weakset = new WeakSet(), numbers = [1, 2,…
Robo Robok
  • 15,554
  • 12
  • 46
  • 87
59
votes
5 answers

How to mock dependencies for unit tests with ES6 Modules

I'm trying to fiddle with Ecmascript 6 modules using webpack + traceur to transpile to ES5 CommonJS, but I'm having trouble successfully unit testing them. I tried using Jest + traceur preprocessor, but the automocking and dependency names seem to…
Evan Layman
  • 3,575
  • 9
  • 26
  • 47
25
votes
1 answer

Override a setter, and the getter must also be overridden

class AbstractClass { constructor() { } set property(value) { this.property_ = value; } get property() { return this.property_; } } class Subclass extends AbstractClass { constructor() { …
user5321531
  • 2,545
  • 5
  • 21
  • 27
23
votes
1 answer

Extending Promises in ES6

I am trying to extend Promise: class PersistedPromise extends Promise { } Then call the static resolve on the derived class to directly create a resolved promise: PersistedPromise.resolve(1) In traceur, this yields: ModuleEvaluationError:…
user663031
21
votes
2 answers

Extending Array with ES6 classes

I have heard that ES6 now finally permits subclassing Array. Here's an example given by class Stack extends Array { constructor() { super() } top() { return this[this.length - 1]; } } var s = new Stack(); s.push("world"); …
user663031
18
votes
6 answers

Should I use Traceur instead of Typescript to target ES5 but be ready for ES6

I'm working on a large code base that could benefit from Typescript, but since eventually the world will be moving to ES6, should I steer the development towards Traceur? I don't want to change Typescript implementations in order to target ES6 (when…
Nikos
  • 6,553
  • 6
  • 43
  • 76
16
votes
9 answers

angularjs http interceptor class (ES6) loses binding to 'this'

I am building and AngularJS app using ES6 classes with traceur transpiling to ES5 in AMD format. in my module I import the interceptor class and register it as a service, and then register this service with the $httpProvider.interceptors in…
14
votes
3 answers

Maven Plugin which transpiles ES6 to ES5 which uses Traceur or Babel

Is there already a preferred way how to transpile ECMAScript6 code to ECMAScript5 using traceur or Babel (formely named 6to5) in a maven project? I have already searched the net without any success.
Daniel K.
  • 5,437
  • 3
  • 15
  • 20
9
votes
1 answer

To what extent does Traceur compile to IE8 compatible Javascript?

A project I'm working on has IE8 as a hard requirement. We would like to potentially use Traceur to start working with some of ES6's improved syntax, but I'm aware that it produces ES5, which is not supported by IE8. Given that I can patch up IE8…
acjay
  • 28,690
  • 4
  • 51
  • 93
8
votes
1 answer

JavaScript ES6 modules + traceur

I'm using ES6 modules transpiled to ES5 with traceur. Transpilation is done via grunt + grunt-traceur Traceur allows you to pick which module handler to use: its own, AMD, commonJS or inline. I have tried most of them, but none seems to to work.…
Razor
  • 19,590
  • 7
  • 50
  • 73
7
votes
2 answers

React and ES6 inheritance

Note: This post has been posted at the time React was NOT supporting ES6 (v12). I have an ES6 class : class BaseClass { getInitialState(){ return {message: 'Hello!'}; } render() { return (
JBE
  • 9,856
  • 6
  • 45
  • 44
6
votes
2 answers

Is it possible to use source maps with Traceur used directly from the page?

I have a small static project written in ES6. It's compiled with Traceur dynamically every reload (for development purposes):