Skip to content

Commit

Permalink
When translating line numbers, check whether the source map entry has…
Browse files Browse the repository at this point in the history
… original values
  • Loading branch information
novemberborn committed Jul 10, 2022
1 parent ac0d75d commit 3572342
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/worker/line-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ const translate = (sourceMap, pos) => {
}

const entry = sourceMap.findEntry(pos.line - 1, pos.column); // Source maps are 0-based

// When used with ts-node/register, we've seen entries without original values. Return the
// original position.
if (entry.originalLine === undefined || entry.originalColumn === undefined) {
return pos;
}

return {
line: entry.originalLine + 1, // Readjust for Acorn.
column: entry.originalColumn,
Expand Down

0 comments on commit 3572342

Please sign in to comment.