Babel decorator runtime helper errors for class with overloaded method
See original GitHub issuePlease paste the output of ember -v
here
ember-cli: 3.7.1 node: 10.11.0 os: darwin x64
Please paste the output of tsc -v
here
Version 3.3.3333
Please paste your tconfig.json
and tslint.json
or eslint.json
(if applicable) below
My tsconfig.json
{ “compilerOptions”: { “target”: “es2017”, “allowJs”: true, “moduleResolution”: “node”, “allowSyntheticDefaultImports”: true, “noImplicitAny”: true, “noImplicitThis”: true, “alwaysStrict”: true, “strictNullChecks”: true, “strictPropertyInitialization”: true, “noFallthroughCasesInSwitch”: true, “noUnusedLocals”: true, “noUnusedParameters”: true, “noImplicitReturns”: true, “noEmitOnError”: false, “noEmit”: true, “inlineSourceMap”: true, “inlineSources”: true, “baseUrl”: “.”, “module”: “es6”, “experimentalDecorators”: true, “paths”: { “ember-typescript-overloads-decorators-bug/tests/": [ "tests/” ], “ember-typescript-overloads-decorators-bug/": [ "app/” ], “": [ "types/” ] } }, “include”: [ “app//*", "tests//", "types/**/” ] }
What are instructions we can follow to reproduce the issue?
git clone https://github.com/simonihmig/ember-typescript-overloads-decorators-bug
Reproduction Case
See the above reproduction repo.
Now about that bug. What did you expect to see?
Hit http://localhost:4200/
and see the default welcome page.
What happened instead?
Runtime error: Uncaught TypeError: Duplicated element (foo)
This happens when a TS class has at least one decorator and one overloaded method. Seems to be an issue with how the decorators and TS Babel plugins interact AFAICT.
The transpiled output of https://github.com/simonihmig/ember-typescript-overloads-decorators-bug/blob/master/app/controllers/application.ts looks like this:
let ApplicationController = (0, _decorate2.default)(null, function (_initialize, _EmberController) {
class ApplicationController extends _EmberController {
constructor(...args) {
super(...args);
_initialize(this);
}
}
return {
F: ApplicationController,
d: [{
kind: "field",
decorators: [_service.inject],
key: "router",
value: void 0
}, {
kind: "field",
key: "foo",
value: void 0
}, {
kind: "field",
key: "foo",
value: void 0
}, {
kind: "method",
key: "foo",
value: function foo() {// dummy
}
}]
};
}, Ember.Controller);
So the overloaded foo
method, which should affect only the typing, not the runtime code, causes multiple foo
fields to be defined for the decorator runtime (@babel/runtime/helpers/esm/decorate
), which then errors because of this.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Maybe related to https://github.com/ember-cli/ember-ajax/issues/428
See the latest revision of https://github.com/emberjs/rfcs/pull/440 for more details