From 357234260afc49646cddc2e9253f2740dd25d8e6 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 10 Jul 2022 14:23:50 +0200 Subject: [PATCH] When translating line numbers, check whether the source map entry has original values --- lib/worker/line-numbers.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/worker/line-numbers.js b/lib/worker/line-numbers.js index c7865f85f..b7031d49b 100644 --- a/lib/worker/line-numbers.js +++ b/lib/worker/line-numbers.js @@ -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,