di.js icon indicating copy to clipboard operation
di.js copied to clipboard

Exception: Constructors of derived class must contain a super call when the memberVariables option is enabled

Open stefanr opened this issue 11 years ago • 1 comments

When the memberVariables option in traceur is enabled I get the following exception:

Uncaught exception: [ 'annotations.js:29:3: Constructors of derived class must contain a super call when the memberVariables option is enabled' ]

Tested with (Options: --annotations --types --member-variables):

import {Injector, Inject} from "di/src";
[...]

This would fix the problem:

[...]
class InjectPromise extends Inject {
  constructor(...tokens) {
    super(...tokens);
    this.isPromise = true;
    this.isLazy = false;
  }
}
[...]

stefanr avatar Feb 03 '15 13:02 stefanr

There were recent changes to Classes over the past few months, one of them is that there is now a TDZ on this, just like there is on let or const declarations, until the super-constructor is called. https://github.com/tc39/ecma262/blob/master/workingdocs/ES6-super-construct%3Dproposal.md (but there have been some more changes since) --- so, the traceur option is just sort of showing you how it's going to be

caitp avatar Feb 03 '15 13:02 caitp