From 8a51e87f384ccb59e19beddad2ec42614c762b2e Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 14 Feb 2023 12:05:51 +0100 Subject: [PATCH] Avoid double-translation of positions (?) --- packages/ts-plugin/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/ts-plugin/src/index.ts b/packages/ts-plugin/src/index.ts index ecbc0ac..6084aa2 100644 --- a/packages/ts-plugin/src/index.ts +++ b/packages/ts-plugin/src/index.ts @@ -55,20 +55,22 @@ const boot: tslib.server.PluginModuleFactory = ({ typescript: ts }) => { span(s: undefined): undefined; span(s: ts.TextSpan | undefined): ts.TextSpan | undefined; span(s: ts.TextSpan | undefined): ts.TextSpan | undefined { - if (s !== void 0) { + if (s !== void 0 && !('__syndicate_translated__' in s)) { const newStart = this.loc(s.start); if (newStart === void 0) throw new Error("Source position unavailable for TextSpan " + JSON.stringify(s)); s.start = newStart; + (s as any).__syndicate_translated__ = true; } return s; } diagnostic(d: T, ds: T[]) { - if (d.start !== void 0) { + if (d.start !== void 0 && !('__syndicate_translated__' in d)) { const p = this.info.targetToSourceMap.get(d.start); if (p === null) return; if (p.firstItem.synthetic) return; d.start = p.firstItem.start.pos + p.offset; + (d as any).__syndicate_translated__ = true; } ds.push(d); }