-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babel decorator runtime helper errors for class with overloaded method #590
Comments
Related code in the demo repo: simonihmig/ember-typescript-overloads-decorators-bug@7f3f038#diff-96934836c1696c832b0197675373e74f |
@simonihmig can you add the ember-cli-typescript version to the writeup there when you get a chance, please? |
At first blush this definitely looks like a bug in the intersection of Babel's TS plugin and its class fields plugin… and it doesn't happen if decorators are present? Quite a specific corner if that's the case. |
Using
You probably mean the opposite, so it doesn't happen if decorators are not present. So both condition must be met: overloaded method + decorator used. Without decorators you don't get this "massively" transpiled structure:
Just a simple ES6 class, with the overloaded type definitions being removed from the final output. It looks as if the decorator babel plugin runs first before the overloaded type definitions are stripped, and while generating this structure above it interprets the overloaded type definitions as separate methods (all with the same Maybe @pzuraq has some ideas? |
We're planning on walking back the decorators transforms to stage 1, so maybe try those transforms and see if it works better? |
See the latest revision of emberjs/rfcs#440 for more details |
Maybe related to ember-cli/ember-ajax#428 |
I believe this has been resolved upstream long since; but in any case the goal will be to align with spec decorators (and will not be something fixed in a TS-specific way). |
Please paste the output of
ember -v
hereember-cli: 3.7.1
node: 10.11.0
os: darwin x64
Please paste the output of
tsc -v
hereVersion 3.3.3333
Please paste your
tconfig.json
andtslint.json
oreslint.json
(if applicable) belowMy tsconfig.json
What are instructions we can follow to reproduce the issue?
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:
So the overloaded
foo
method, which should affect only the typing, not the runtime code, causes multiplefoo
fields to be defined for the decorator runtime (@babel/runtime/helpers/esm/decorate
), which then errors because of this.The text was updated successfully, but these errors were encountered: