From c19fb3365da095046ff342decf465e0c725828e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:39:52 +0000 Subject: [PATCH] fix(frontend): import Plotly types explicitly so tsc passes on TypeScript 5 and 7 TypeScript 7 no longer resolves the global Plotly type namespace that @types/plotly.js declares, so Plotly.Data and Plotly.Layout failed with TS2503 in figure/FigureEditor.tsx and figure/export.ts. Import the types. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZkJwTENF5faco36Cn5 --- frontend/src/figure/FigureEditor.tsx | 3 ++- frontend/src/figure/export.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/figure/FigureEditor.tsx b/frontend/src/figure/FigureEditor.tsx index 41ca25df..1d8b9932 100644 --- a/frontend/src/figure/FigureEditor.tsx +++ b/frontend/src/figure/FigureEditor.tsx @@ -2,6 +2,7 @@ // Licensed under the GNU Affero General Public License version 3 (AGPLv3). import { useEffect, useLayoutEffect, useRef, useState } from 'react' import Plotly from 'plotly.js-dist-min' +import type { Data as PlotlyData } from 'plotly.js' import { api } from '../api/client' import { errorMessage } from '../api/errorMessage' import type { AnnotationSource, ComparisonRunSpec } from '../api/types' @@ -89,7 +90,7 @@ function PanePlot({ study, pane, doc, showLegend, w, h, version, onEntries }: { if (cancelled) return const fig = paneFigure(raw, pane, doc, { showLegend, widthPx: w, heightPx: h }) onEntries(legendEntries(fig)) - return Plotly.react(el, fig.data as Plotly.Data[], fig.layout, { staticPlot: true, displayModeBar: false }) + return Plotly.react(el, fig.data as PlotlyData[], fig.layout, { staticPlot: true, displayModeBar: false }) }) .catch(e => { if (!cancelled) setError(errorMessage(e)) }) .finally(() => { if (!cancelled) setLoading(false) }) diff --git a/frontend/src/figure/export.ts b/frontend/src/figure/export.ts index c33684b3..7d3973bd 100644 --- a/frontend/src/figure/export.ts +++ b/frontend/src/figure/export.ts @@ -1,6 +1,7 @@ // © 2026 Joshua Benjamin Jewell. All rights reserved. // Licensed under the GNU Affero General Public License version 3 (AGPLv3). import Plotly from 'plotly.js-dist-min' +import type { Data as PlotlyData, Layout as PlotlyLayout } from 'plotly.js' import { PX_PER_MM, PX_PER_PT, MM_PER_IN, figureGeometry, titlePt, type FigureDoc } from './types' import { layoutLegend, legendEntries, mergeEntries } from './legend' import type { PlotSpec } from './charts' @@ -11,7 +12,7 @@ const SVG_NS = 'http://www.w3.org/2000/svg' /** Plotly's SVG of one pane. */ async function paneSvg(fig: PlotSpec): Promise { const w = fig.layout.width as number, h = fig.layout.height as number - const url = await Plotly.toImage({ data: fig.data as Plotly.Data[], layout: fig.layout as Partial }, + const url = await Plotly.toImage({ data: fig.data as PlotlyData[], layout: fig.layout as Partial }, { format: 'svg', width: w, height: h }) const text = decodeURIComponent(url.slice(url.indexOf(',') + 1)) return new DOMParser().parseFromString(text, 'image/svg+xml').documentElement as unknown as SVGSVGElement