-
-
Notifications
You must be signed in to change notification settings - Fork 541
Closed
Description
For files that don't have import
or export
statements ts-node test.ts
fails when there is await
function:
ReferenceError: __awaiter is not defined
test.ts
(async () => {})().catch(console.error);
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"sourceMap": true,
"noEmitHelpers": true,
"importHelpers": true,
"strictNullChecks": false,
"baseUrl": ".",
"paths": [],
"lib": [ "es2017"]
},
"exclude": [
"node_modules",
"dist"
]
}
Of course, tslib
is installed. And it starts working normally when export default {}
is added.
It was different in older ts-node before it was updated (likely 2.x), an error appeared for all module-scoped const
:
Cannot redeclare block-scoped variable ...
And it disappeared when import
or export
statements were added, so it looks like a file wasn't compiled as ES6 module.
ts-node 3.0.4,
typescript 2.3.4
tslib 1.7.1
node 6.10.3