Expecting ts-node to report accurate stack frame, pointing to the original typescript file.
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)
$ npx [email protected] test1.tsnpx: 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 [email protected] 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)
at c:\temp\tsnode-issue\test1.ts:9:9 incorrect with [email protected]at c:\temp\tsnode-issue\test1.ts:8:9 '(correct with [email protected]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)
https://github.com/TypeStrong/ts-node-repros/pull/3
{}
Thank you for the detailed report. This may be the same as #1037, which was fixed in #1038 but not yet published. Are you able to test with the latest master code?
npm install 'TypeStrong/ts-node#master'
Thank you for the detailed report. This may be the same as #1037, which was fixed in #1038 but not yet published. Are you able to test with the latest
mastercode?npm install 'TypeStrong/ts-node#master'
I have a similar issue and the latest code in master branch works
I hope you're going to publish the fix soon since this bug seems to be affecting Mocha Test Explorer (which uses stack traces to detect the test locations in the code).
I should have time to publish a release on Saturday. Unfortunately I am swamped at work this week, so that's the soonest I will be able to work on ts-node stuff.
Maybe @blakeembrey is able to publish a new release in the meantime?
@hbenl @erossignon @rinick
Published 8.10.2 which includes this fix. Thanks for your patience.
Thanks to @jugglingthebits for testing the release.
Most helpful comment
@hbenl @erossignon @rinick
Published 8.10.2 which includes this fix. Thanks for your patience.
Thanks to @jugglingthebits for testing the release.