You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
I am trying to start Mocha using ESM and TS-Node. Everytime I do so with a .ts file as target, the following error occurs: error TS1108: A 'return' statement can only be used within a function body.
The output code in the error message indeed shows a return statement not wrapped inside a function: const _1f5=exports;return _1f5.r((function *(exports,require){"use strict";let something;_1f5.w("./export",[["something",["something"],function(v){something=v}]]);yield;_1f5.s();
The NPM script is: mocha -r esm -r ts-node/register *.ts
Using .js files as target does not cause this error.
My assumption is that ESM may convert the import code erroneous in this case.
For easier reproduction of the error, here is the minimal example to check out and test: https://github.com/MetalSkotty/esm_ts-node_mocha_bug
Usage: npm run test:ts uses the .ts files. npm run test:js uses the .js files.
The text was updated successfully, but these errors were encountered:
I am trying to start Mocha using ESM and TS-Node. Everytime I do so with a .ts file as target, the following error occurs:
error TS1108: A 'return' statement can only be used within a function body.
The output code in the error message indeed shows a return statement not wrapped inside a function:
const _1f5=exports;return _1f5.r((function *(exports,require){"use strict";let something;_1f5.w("./export",[["something",["something"],function(v){something=v}]]);yield;_1f5.s();
The NPM script is:
mocha -r esm -r ts-node/register *.ts
Using .js files as target does not cause this error.
My assumption is that ESM may convert the import code erroneous in this case.
For easier reproduction of the error, here is the minimal example to check out and test: https://github.com/MetalSkotty/esm_ts-node_mocha_bug
Usage:
npm run test:ts
uses the .ts files.npm run test:js
uses the .js files.The text was updated successfully, but these errors were encountered: