Typescript: Emit with name-colliding helper functions is incorrect when target >=ES2015

Created on 23 Sep 2019  ·  3Comments  ·  Source: microsoft/TypeScript


TypeScript Version: 3.6.3


Search Terms: helper rename

Code

// @target: es2015

declare function __awaiter(): void;
class C {
    async func() {
    }
}

Expected behavior:
Some sort of error is emitted (when the target requires the helper) notifying the user that the generated code will not work OR maybe the helper is emitted with an alternative name.

Actual behavior:
The emit declares an __awaiter function, but attempts to call __awaiter_1.

Playground Link: here

Related Issues:

Bug

Most helpful comment

Fix: Add more underscores 😅

All 3 comments

Fix: Add more underscores 😅

Is there any news on this? I ran into a similar issue when an npm package I pulled in already had the helper __awaiter defined so calls changed to __awaiter_1 but no __awaiter_1 function ever got defined. Had to write a hack post-build script to set __awaiter_1 = __awaiter after compilation, would be great if this got fixed.

This looks to be a duplicate of #33269, which was fixed by #36541.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fwanicka picture fwanicka  ·  3Comments

uber5001 picture uber5001  ·  3Comments

blendsdk picture blendsdk  ·  3Comments

wmaurer picture wmaurer  ·  3Comments

CyrusNajmabadi picture CyrusNajmabadi  ·  3Comments