Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 7454a1f

Browse files
committed
fix(plugin-charts): type the compareTo test's parameter at the producer's declaration
Second union-only defect with objectui#8895, measured on the merge of the two heads and NOT previously reported: `renderChart(compareTo: unknown, …)` stops compiling once #8895 declares `ObjectChartSchema.compareTo` as `DashboardWidget['compareTo']`, because on this branch the key still rides `BaseSchema`'s index signature. It was masked rather than absent: `type-check` is `tsc --noEmit && tsc -p tsconfig.test.json`, so the drill-title error in `ObjectChart.tsx` short-circuited the test project and hid every error it would have reported. Running the test project alone on the pre-rework union shows both. Typed at `DashboardWidget['compareTo']` — the symbol #8895 binds to and the declaration the value actually comes from (`DashboardRenderer` forwards `widget.compareTo` verbatim). All four call sites already pass that shape. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
1 parent 0d3d375 commit 7454a1f

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

‎packages/plugin-charts/src/__tests__/ObjectChart.compareTo.test.tsx‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ vi.mock('../ChartRenderer', () => ({
3232
}));
3333

3434
import { ObjectChart } from '../ObjectChart';
35+
import type { DashboardWidget as SpecDashboardWidget } from '@objectstack/spec/ui';
3536

3637
/**
3738
* objectui#4106 — answer ObjectChart's option-color probe from a double.
@@ -94,7 +95,28 @@ const comparisonFromOf = (src: { aggregate: any }) =>
9495
.map((c: any[]) => String(c[1].filter.close_date.$gte))
9596
.find((from: string) => from !== CURRENT_FROM);
9697

97-
const renderChart = (compareTo: unknown, dataSource: unknown) =>
98+
/**
99+
* ⚠️ `compareTo` is typed at the PRODUCER's own declaration rather than
100+
* `unknown`, and the reason is a measurement rather than tidiness.
101+
*
102+
* `DashboardRenderer` composes this node with `compareTo: widget.compareTo`,
103+
* forwarding the dashboard widget's key verbatim — so
104+
* `DashboardWidget['compareTo']` is literally where every value that reaches
105+
* this prop comes from. All four call sites below already pass exactly that
106+
* shape (`{ kind }`, `{ kind, dimension }`, or nothing), so nothing this file
107+
* expresses is lost.
108+
*
109+
* What it buys: objectui#8885 (PR objectui#8895) declares `compareTo` on
110+
* `ObjectChartSchema` bound to that same symbol. With `unknown` here, the
111+
* literal below stops compiling the moment the two PRs are UNIONISED — a defect
112+
* neither branch can see alone, because on this branch the key still rides
113+
* `BaseSchema`'s index signature. Measured on the merge of the two heads: the
114+
* union's `tsc -p tsconfig.test.json` reported this line, and it was masked in
115+
* the obvious reading because `type-check` is `tsc --noEmit && tsc -p
116+
* tsconfig.test.json` — the `&&` short-circuits, so the first error hides every
117+
* error the TEST project would have reported.
118+
*/
119+
const renderChart = (compareTo: SpecDashboardWidget['compareTo'], dataSource: unknown) =>
98120
render(
99121
<ObjectChart
100122
schema={{

0 commit comments

Comments
 (0)