Skip to content

Commit b215626

Browse files
authored
fix(types): allow inferred consumer declaration emit (#157)
* fix(types): allow inferred consumer declaration emit * chore: refresh declaration-fix comparison evidence * docs: align comparison prose with measured revision
1 parent 327f488 commit b215626

14 files changed

Lines changed: 143 additions & 16 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/charts': patch
3+
---
4+
5+
Allow exported marks and inferred chart definitions to emit portable TypeScript declarations by exposing the core type declaration module and exporting its chart-spec interfaces.

‎API-FRICTION.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ observed difficulty from examples, production migrations, tests, and agent
55
evaluations so later API, documentation, and TanStack Intent skill work is
66
based on evidence.
77

8-
Last updated: 2026-09-09
8+
Last updated: 2026-09-30
99

1010
## Triage rule
1111

@@ -342,6 +342,7 @@ Each entry records:
342342
| F-303 | Focus mark groups ignored their mark motion | API | resolved |
343343
| F-304 | Gradient resources hid cross-renderer ownership | API | resolved |
344344
| F-305 | Categorical legend styling required a replacement renderer | API | resolved |
345+
| F-306 | Inferred consumer declarations could not name core types | Tooling | resolved |
345346

346347
## Findings
347348

@@ -9026,3 +9027,21 @@ Each entry records:
90269027
line-dot centers, resolved label paint, and single-node and multi-node custom
90279028
indicators. The composed and pie catalog examples use the built-in legend
90289029
instead of application-owned layout.
9030+
9031+
### F-306 - Inferred consumer declarations could not name core types
9032+
9033+
- Status: resolved
9034+
- Severity: high
9035+
- Owner: Tooling
9036+
- Observed in: the issue #156 reproduction against a freshly packed core package
9037+
- Friction: exported `barY` results and inferred `defineChart` wrappers passed
9038+
ordinary typechecking but failed declaration emit. The declaring `types`
9039+
module was unreachable through package exports, and `StoredChartSpec` and
9040+
`ChartSpecBase` were not exported.
9041+
- Decision: expose the declaring module at `@tanstack/charts/types/core` and
9042+
export the two spec interfaces. Preserve the existing platform-neutral
9043+
type barrel and inferred authoring APIs.
9044+
- Verification: the packed-consumer gate emits declarations for both exports
9045+
with the pinned TypeScript compiler and typechecks the generated declarations
9046+
as a downstream consumer. Packed runtime, React Native, and seven framework
9047+
adapter gates pass. All 60 comparison bundle measurements are unchanged.

‎benchmarks/comparison/bundle-baseline.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"schemaVersion": 4,
3-
"generatedAt": "2026-09-10T04:50:31.051Z",
3+
"generatedAt": "2026-09-30T14:33:25.271Z",
44
"packageVersions": {
5-
"tanstack": "0.17.0",
5+
"tanstack": "0.18.0",
66
"chartjs": "4.5.1",
77
"echarts": "6.1.0",
88
"recharts": "3.10.1",
@@ -11,8 +11,8 @@
1111
"sources": {
1212
"tanstack": {
1313
"kind": "workspace",
14-
"revision": "8bab934c07762e335108b12687e3587cddc1288e",
15-
"inputDigest": "sha256:73e433a9402a39e35a475fac52af5655016beae0c80c3a9950e47425ef4cd965"
14+
"revision": "4bbe1c5690789064f2c525226321baa5817af39a",
15+
"inputDigest": "sha256:b07d6531a6ef39c0c4e9295f2b3d5335e67a38f9255517426f757a3efedecaad"
1616
},
1717
"chartjs": {
1818
"kind": "package",

‎benchmarks/conformance/previews/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": 1,
33
"width": 288,
44
"height": 192,
5-
"sourceHash": "33ff2cb340686f5c9fedbeb0f14be908c1f28a6bb5e55483a6fe38fc2a213434",
5+
"sourceHash": "4b5e1de199530168188592df376662b15aa5c570dc24bc742e761d312e5fe141",
66
"assets": [
77
{
88
"id": "01-line-gaps",

‎docs/comparison.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ turning untested behavior into a checkmark.
1212

1313
| Library | Package | Measured source |
1414
| -------------------------------------------------------------------------------------- | -------------------- | ------------------- |
15-
| [TanStack Charts](./overview.md) | `@tanstack/charts` | workspace `8bab934` |
15+
| [TanStack Charts](./overview.md) | `@tanstack/charts` | workspace `4bbe1c5` |
1616
| [Chart.js](https://www.chartjs.org/docs/latest/) | `chart.js` | npm `4.5.1` |
1717
| [Apache ECharts](https://echarts.apache.org/handbook/en/best-practices/canvas-vs-svg/) | `echarts` | npm `6.1.0` |
1818
| [Recharts](https://recharts.github.io/en-US/) | `recharts` | npm `3.10.1` |
1919
| [Observable Plot](https://observablehq.com/plot/features/plots) | `@observablehq/plot` | npm `0.6.17` |
2020

2121
The competitor versions are exact package pins, not latest versions inferred
22-
at page render time. The measured TanStack workspace revision is `8bab934`.
22+
at page render time. The measured TanStack workspace revision is `4bbe1c5`.
2323

2424
## Capability matrix
2525

@@ -90,7 +90,7 @@ output model.
9090

9191
## Bundle snapshot
9292

93-
Baseline date: `2026-09-10`.
93+
Baseline date: `2026-09-30`.
9494

9595
Controlled ranges cover 12 independently built, minified browser consumers:
9696
line, bar, area, and scatter at basic, interactive, and advanced tiers. Only

‎docs/reference/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ aggregate `/scales` export.
192192
| `@tanstack/charts/transform/fold` | `fold`, `FoldField`, `FoldOutputNames`, `FoldOptions`, and `FoldDatum` |
193193
| `@tanstack/charts/transform/waterfall` | `waterfall`, `WaterfallKind`, `WaterfallOptions`, `WaterfallDatum`, `WaterfallStepDatum`, and `WaterfallTotalDatum` |
194194
| `@tanstack/charts/types` | Universal definition, mark, scene, runtime, focus, and tooltip-model types |
195+
| `@tanstack/charts/types/core` | Core type declarations used by inferred declaration emit |
195196
| `@tanstack/charts/vector` | `vector` |
196197
| `@tanstack/charts/view` | `composeViews`, `fill`, `grid`, `layer`, `inset`, scale-link helpers, `viewGrid`, and view composition types |
197198
| `@tanstack/charts/violin` | `violinY`, `violinX`, `ViolinYOptions`, `ViolinXOptions`, `ViolinPosition`, `ViolinYCurve`, and `ViolinXCurve` |

‎docs/reference/types.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ libraries can import the same definition, mark, scene, runtime, focus, and
1313
tooltip-model contracts from `@tanstack/charts/types`; DOM host and renderer
1414
types remain available from the root.
1515

16+
The `@tanstack/charts/types/core` entry exposes the module that declares the
17+
core types. TypeScript uses this entry when emitting inferred declarations
18+
for exported marks and chart definitions. You do not need to annotate those
19+
exports or import package-internal files.
20+
21+
This entry also exposes the supporting inference and extension contracts:
22+
23+
| Type | Purpose |
24+
| -------------------------------- | ------------------------------------------------------------- |
25+
| `ChartSpecBase` | Shared guide, color, resource, and layout options |
26+
| `StoredChartSpec` | Stored marks and scale registry used by definition inference |
27+
| `CheckedChartSpec` | Checks a stored spec against its marks' scale requirements |
28+
| `MarkScaleBindings` | Optional named x and y scale bindings |
29+
| `MarkChannelOutput` | Inferred channel output with a widened fallback |
30+
| `MarkCallOptions` | Combines inferred selectors with non-inferred options |
31+
| `DecorativeChartMark` | Marks geometry as decorative while retaining its source types |
32+
| `ChartLegendPlacement` | Top or bottom placement for a color legend |
33+
| `ChartHostControl` | Scene descriptor for an optional host control |
34+
| `ChartHostControlExtensionToken` | Renderer-neutral identity and factory for a host control |
35+
1636
## Callback shape
1737

1838
Public callbacks take at most two arguments: primary data or purpose first,

‎packages/charts-core/docs/comparison.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ turning untested behavior into a checkmark.
1212

1313
| Library | Package | Measured source |
1414
| -------------------------------------------------------------------------------------- | -------------------- | ------------------- |
15-
| [TanStack Charts](./overview.md) | `@tanstack/charts` | workspace `8bab934` |
15+
| [TanStack Charts](./overview.md) | `@tanstack/charts` | workspace `4bbe1c5` |
1616
| [Chart.js](https://www.chartjs.org/docs/latest/) | `chart.js` | npm `4.5.1` |
1717
| [Apache ECharts](https://echarts.apache.org/handbook/en/best-practices/canvas-vs-svg/) | `echarts` | npm `6.1.0` |
1818
| [Recharts](https://recharts.github.io/en-US/) | `recharts` | npm `3.10.1` |
1919
| [Observable Plot](https://observablehq.com/plot/features/plots) | `@observablehq/plot` | npm `0.6.17` |
2020

2121
The competitor versions are exact package pins, not latest versions inferred
22-
at page render time. The measured TanStack workspace revision is `8bab934`.
22+
at page render time. The measured TanStack workspace revision is `4bbe1c5`.
2323

2424
## Capability matrix
2525

@@ -90,7 +90,7 @@ output model.
9090

9191
## Bundle snapshot
9292

93-
Baseline date: `2026-09-10`.
93+
Baseline date: `2026-09-30`.
9494

9595
Controlled ranges cover 12 independently built, minified browser consumers:
9696
line, bar, area, and scatter at basic, interactive, and advanced tiers. Only

‎packages/charts-core/docs/reference/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ aggregate `/scales` export.
192192
| `@tanstack/charts/transform/fold` | `fold`, `FoldField`, `FoldOutputNames`, `FoldOptions`, and `FoldDatum` |
193193
| `@tanstack/charts/transform/waterfall` | `waterfall`, `WaterfallKind`, `WaterfallOptions`, `WaterfallDatum`, `WaterfallStepDatum`, and `WaterfallTotalDatum` |
194194
| `@tanstack/charts/types` | Universal definition, mark, scene, runtime, focus, and tooltip-model types |
195+
| `@tanstack/charts/types/core` | Core type declarations used by inferred declaration emit |
195196
| `@tanstack/charts/vector` | `vector` |
196197
| `@tanstack/charts/view` | `composeViews`, `fill`, `grid`, `layer`, `inset`, scale-link helpers, `viewGrid`, and view composition types |
197198
| `@tanstack/charts/violin` | `violinY`, `violinX`, `ViolinYOptions`, `ViolinXOptions`, `ViolinPosition`, `ViolinYCurve`, and `ViolinXCurve` |

‎packages/charts-core/docs/reference/types.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ libraries can import the same definition, mark, scene, runtime, focus, and
1313
tooltip-model contracts from `@tanstack/charts/types`; DOM host and renderer
1414
types remain available from the root.
1515

16+
The `@tanstack/charts/types/core` entry exposes the module that declares the
17+
core types. TypeScript uses this entry when emitting inferred declarations
18+
for exported marks and chart definitions. You do not need to annotate those
19+
exports or import package-internal files.
20+
21+
This entry also exposes the supporting inference and extension contracts:
22+
23+
| Type | Purpose |
24+
| -------------------------------- | ------------------------------------------------------------- |
25+
| `ChartSpecBase` | Shared guide, color, resource, and layout options |
26+
| `StoredChartSpec` | Stored marks and scale registry used by definition inference |
27+
| `CheckedChartSpec` | Checks a stored spec against its marks' scale requirements |
28+
| `MarkScaleBindings` | Optional named x and y scale bindings |
29+
| `MarkChannelOutput` | Inferred channel output with a widened fallback |
30+
| `MarkCallOptions` | Combines inferred selectors with non-inferred options |
31+
| `DecorativeChartMark` | Marks geometry as decorative while retaining its source types |
32+
| `ChartLegendPlacement` | Top or bottom placement for a color legend |
33+
| `ChartHostControl` | Scene descriptor for an optional host control |
34+
| `ChartHostControlExtensionToken` | Renderer-neutral identity and factory for a host control |
35+
1636
## Callback shape
1737

1838
Public callbacks take at most two arguments: primary data or purpose first,

0 commit comments

Comments
 (0)