-
-
Notifications
You must be signed in to change notification settings - Fork 542
Closed
Labels
Description
Expected Behavior
Expecting ts-node to report accurate stack frame, pointing to the original typescript file.
Steps to reproduce the problem
package.json
{
"name": "tsnode-issue",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"typescript": "^3.9.3"
}
}
test.ts
/* some comment */
function someFunc() {
throw new Error("Error");
}
; (() => {
try {
/* some comment */
someFunc();
}
catch (err) {
/* some comment */
console.log("Error Found", err);
}
})();( no tsconfig file necessary)
Minimal reproduction
- run
$ npx ts-node@8.10.0 test1.ts - observe the result
npx: installed 8 in 2.249s
Error Found Error: Error
at someFunc (c:\temp\tsnode-issue\test1.ts:3:11)
at c:\temp\tsnode-issue\test1.ts:9:9
at Object.<anonymous> (c:\temp\tsnode-issue\test1.ts:15:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (C:\Users\eross\AppData\Roaming\npm-cache\_npx\23236\node_modules\ts-node\src\index.ts:858:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\eross\AppData\Roaming\npm-cache\_npx\23236\node_modules\ts-node\src\index.ts:861:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
-
now run with older version
$ npx ts-node@8.9.1 test1.ts -
observe the result
npx: installed 8 in 2.184s
Error Found Error: Error
at someFunc (c:\temp\tsnode-issue\test1.ts:3:11)
at c:\temp\tsnode-issue\test1.ts:8:9
at Object.<anonymous> (c:\temp\tsnode-issue\test1.ts:14:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (C:\Users\eross\AppData\Roaming\npm-cache\_npx\17244\node_modules\ts-node\src\index.ts:839:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\eross\AppData\Roaming\npm-cache\_npx\17244\node_modules\ts-node\src\index.ts:842:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
- spot the that the stack frame is wrong
at c:\temp\tsnode-issue\test1.ts:9:9incorrect with ts-node@8.10
where it should report
at c:\temp\tsnode-issue\test1.ts:8:9'(correct with ts-node@8.9
In real production, the line number discrepancy can be large and annoying as it make it almost impossible to identify where the exception was raised ( annoying when doing TDD)
Specifications
- ts-node version: success with 8.9 : failure with 8.10.1 and 8.10.0
- node version: 10.20.1
- TypeScript version: 3.9.3
- tsconfig.json, if you're using one:
{}
- Operating system and version:
- If Windows, are you using WSL or WSL2?:
Bug can be reproduced on Windows from a DOS box,
cannot exhibit bug in WSL