-
Notifications
You must be signed in to change notification settings - Fork 6k
Errors have wrong line numbers when running .ts files #32096
Description
Version: Deno 2.6.8
Consider this simple file, bad.ts:
function func2() {
throw new Error('bad')
}
function func1() {
func2()
}
func1()The stack trace should reveal lines 2, 7, 11:
However, deno run results in a stack trace with lines 2, 5, 7:
$ deno bad.ts
error: Uncaught (in promise) Error: bad
throw new Error('bad')
^
at func2 (file:///C:/Users/edemaine/Projects/Civet/bad.ts:2:9)
at func1 (file:///C:/Users/edemaine/Projects/Civet/bad.ts:5:3)
at file:///C:/Users/edemaine/Projects/Civet/bad.ts:7:1
at Object.<anonymous> (file:///C:/Users/edemaine/Projects/Civet/bad.ts:9:3)
at Module._compile (node:module:759:34)
at loadMaybeCjs (node:module:784:10)
at Object.Module._extensions..js (node:module:769:12)
at Module.load (node:module:677:32)
at Module._load (node:module:535:12)
at file:///C:/Users/edemaine/Projects/Civet/bad.ts:5:26Renaming the file to bad.js results in the correct line numbers:
$ deno bad.js
error: Uncaught (in promise) Error: bad
throw new Error('bad')
^
at func2 (file:///C:/Users/edemaine/Projects/Civet/bad.js:2:8)
at func1 (file:///C:/Users/edemaine/Projects/Civet/bad.js:7:2)
at file:///C:/Users/edemaine/Projects/Civet/bad.js:11:1
at Object.<anonymous> (file:///C:/Users/edemaine/Projects/Civet/bad.js:13:3)
at Module._compile (node:module:759:34)
at loadMaybeCjs (node:module:784:10)
at Object.Module._extensions..js (node:module:769:12)
at Module.load (node:module:677:32)
at Module._load (node:module:535:12)
at file:///C:/Users/edemaine/Projects/Civet/bad.js:5:26I suspect this is the same issue as #25349, but perhaps easier to track down, as it's a small reproduction and involves the CLI instead of Chrome.
Originally, this issue came to me via DanielXMoore/Civet#1845 as part of a more complicated scenario with inline sourcemaps, which we now have thanks to #31268. Perhaps there are further issues in stacking two sourcemaps (one from the automatic .ts conversion, and one from inline sourcemap), but we can cross that bridge once we figure out what's going on with automatic .ts conversion sourcemap.