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
Top-level await doesn't work with ts-node typescript files. #580
Comments
Well spotted, I managed to get it to work with following:
the order of requires is crucial. For the same reason Is might be possible to set that global ignore or something similar for TS1308 from esm if top-level await is enabled before ts-node/register is activated since it's very specific to this. Unfortunately TS2304 is more difficult since |
Did you set the TS target to |
Target doesn't matter, as long as it's at least |
Based on the comment from the linked issue:
I'm not a TS user so I don't know if this still holds true. |
it still does |
If I remove the parenthesis I get this instead
|
.esmrc:
{ "await": true }
topAwait.js|ts:
console.log(await (new Promise((resolve) => resolve('ok'))));
Above code works if it's run with both
node -r esm topAwait.js
orts-node -r esm topAwait.js
.if run with
ts-node -r esm topAwait.ts
, It fails withtopAwait.ts(1,13): error TS2304: Cannot find name 'await'.
The text was updated successfully, but these errors were encountered: