Repository navigation
fix(visx): type SVG props with octane's attribute bag - #755
Merged
Merged
Conversation
@octanejs/visx ships raw source and points its exports at it, so a consumer's TypeScript program compiles every reachable module. React's SVGProps is not assignable to octane's intrinsic element bag — handlers receive native DOM events, className composes clsx-style, class/for are accepted natively, and children is a renderable — so every component that spread it produced errors in a consumer's program. Forty-two modules move from React's SVGProps to Octane.SVGProps, following the pattern already established in grid/, group/, responsive/, and shape/. Alongside that: capitalized JSX aliases replace createElement where a React FunctionComponent | ComponentClass union reached octane's createElement, which takes a ComponentBody and cannot call a constructor; a real declaration for d3-interpolate-path; and a render-prop implementation of TooltipPositionContext.Consumer, which octane deliberately lacks. In-src diagnostics under `tsrx-tsc -p packages/visx/tsconfig.json` drop from 158 to 90, measured by redirecting to a file: piping that command truncates its output and undercounts. The conversion left 24 parity assertions failing. Probing every module export found 55 diverging components, in categories the existing flat attribute-bag carve-out covers only 20 of. The reason the rest fell through is that an attribute bag reaches a component's surface in three shapes, and the normalization only handled the first: spread flat into the props, held by an object-typed member (tickLabelProps, backgroundProps, lineProps, glyphStyle), or carried by a RENDER PROP'S ARGUMENT — Axis passes AxisRendererProps to children, and the normalization kept a function's argument exact while collapsing only its return. It now recurses through all three, treating a member as a bag when it has a className key. Recursion only ever collapses more of the same divergence on both sides, so it cannot turn a passing comparison into a failing one. That keeps real member-by-member checking where a key-only pin would otherwise have been the fallback. A regression test confirms the reach: retyping AxisRendererProps.horizontal fails nine assertions that a key-for-key pin would not have noticed at all. Only four surfaces stay pinned key-for-key — SplitLinePath, whose styles members keep className a plain string so it can forward to LinePath; the two area stacks, whose children are ReactElement<AreaSeriesProps>, putting the bag inside a React element type rather than a renderable hole; and Drag, whose divergence is the native event union rather than a bag. Twenty-three surfaces (the clip-paths, gradients, markers, and Threshold) additionally take an optional id where upstream requires one, because they generate a fallback with useStableId. That predates this work and is exactly the one-directional relationship the module-level Extends asserts already describe, so a new AttributeBagNormalizedPropsExtends keeps that direction with the bag divergences collapsed. BrushProps.selectedBoxStyle holds a bag rather than spreading one, and is spelled out on the upstream side like renderBrushHandle already was. OctaneOnlyAttributeKeys was also incomplete: octane's bags add exactly class, for, hidden, and tabindex, and drop nothing. Those extras are optional, so the member-by-member comparisons tolerate them, but a key-for-key pin cannot, so PropsShapeEqual excludes the full set. _Network drops from Equal to Extends like its peers. It held as Equal only because tsgo reads the generated .tsrx.d.ts, which annotates returns as React's JSX.Element; compiling the published .tsrx sources, which is what a consumer's program does, shows Graph, Links, and Nodes returning octane's nominal element type. RenderableNormalizedPropsEqual is now unused and is removed. This is partial progress on strict consumer type-checking for visx, not its completion. 90 in-src diagnostics remain, 7 of them the dropped `let __spread_props` compiler defect tracked as octane issue 737, so the package keeps its SOURCE_PUBLICATION_DEBT entry and continues to validate through tsgo. Co-authored-by: Claude Opus 5 <[email protected]>
trueadm
marked this pull request as ready for review
August 14, 2026 09:23
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit b221618. Configure here.
9 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
@octanejs/visxships raw source and points its exports at it, so a consumer's TypeScript program compiles every reachable module. React'sSVGPropsis not assignable to octane's intrinsic element bag — handlers receive native DOM events,classNamecomposes clsx-style,class/forare accepted natively, andchildrenis a renderable — so every component that spread it produced errors in a consumer's program.Forty-two modules move to
Octane.SVGProps, following the pattern already established ingrid/,group/,responsive/, andshape/. In-src diagnostics undertsrx-tsc -p packages/visx/tsconfig.jsondrop from 158 to 90.This is partial progress on #721, not its completion — see Risk / follow-ups.
Why the parity suite needed real work, not an exemption
The conversion left 24 parity assertions failing. Probing every module export found 55 diverging components, and the existing flat attribute-bag carve-out covers only 20 of them.
The reason the rest fell through is that an attribute bag reaches a component's surface in three shapes, and the normalization only handled the first:
tickLabelProps,backgroundProps,lineProps,glyphStyle);AxispassesAxisRendererPropstochildren, and the normalization kept a function's argument exact while collapsing only its return.It now recurses through all three, treating a member as a bag when it has a
classNamekey. Recursion only ever collapses more of the same divergence on both sides, so it cannot turn a passing comparison into a failing one.That matters because the alternative was pinning those surfaces by key name only, which checks no types at all. The reach is regression-tested: retyping
AxisRendererProps.horizontalfrombooleantostringfails nine assertions that a key-for-key pin would not have noticed.Resulting assertion tiers:
Equal— member-by-memberExtends— one-directionalThe four key-for-key surfaces each have a concrete reason:
SplitLinePathkeepsstyles.classNamea plain string so it can forward toLinePath; the two area stacks take children asReactElement<AreaSeriesProps>, putting the bag inside a React element type rather than a renderable hole; andDragdiverges on the native event union rather than a bag.Twenty-three surfaces (clip-paths, gradients, markers,
Threshold) additionally take an optionalidwhere upstream requires one, because they generate a fallback withuseStableId. That predates this branch and is exactly the one-directional relationship the module-levelExtendsasserts already describe, so they keep that direction with the bag divergences collapsed._Networkdrops fromEqualtoExtendslike its peers. It held asEqualonly becausetsgoreads the generated.tsrx.d.ts, which annotates returns as React'sJSX.Element; compiling the published.tsrxsources — what a consumer's program actually does — showsGraph,Links, andNodesreturning octane's nominal element type.Changes
SVGPropstoOctane.SVGProps.createElementwhere a ReactFunctionComponent | ComponentClassunion reached octane'screateElement, which takes aComponentBodyand cannot call a constructor.d3-interpolate-path.TooltipPositionContext.Consumer, which octane deliberately lacks.tests/types/parity.test-d.ts: recursive bag normalization, per-component carve-outs with the reason recorded for each, andOctaneOnlyAttributeKeyscompleted toclass/for/hidden/tabindex(measured: octane's bags add exactly those and drop nothing).Validation
pnpm format:checkpnpm typecheckpnpm test— see belowpnpm vitest run --project visx --project visx-ssr --project visx-differential(13 files, 40 tests)pnpm packages:source:check,pnpm sync(no drift),pnpm exec changeset statustsgo --noEmit -p packages/visx/tsconfig.json: 24 errors → 0pnpm testwas run in full and came back red: 12 tests inpackages/octane/tests/browser/native-change/native-change.test.tsfailed on 30 s Playwright timeouts. The same file passes 12/12 in isolation, and this diff touches nothing outsidepackages/visx, so this reads as resource contention in a 2 181-file local run rather than a regression — but it is recorded here rather than ticked.All counts were measured by redirecting to a file. Piping
tsrx-tsctruncates its output and undercounts.Risk / follow-ups
packages/visx/tsconfig.jsonkeeps itsSOURCE_PUBLICATION_DEBTentry and continues to validate throughtsgo. Not closing Several published TSRX source bindings fail strict consumer tsrx-tsc typechecking #721.let __spread_propsdeclaration tracked in Virtual TSX drops thelet __spread_propsdeclaration for a host element withrefplus a spread outside a directreturn, producing TS2304 #737 (text/Text.tsrx,tooltip/tooltips/Tooltip.tsrx,geo/projections/Projection.tsrx). They also own the 2 assertions still failing inparity.test-d.tsundertsrx-tsc(_Text,_TooltipWithBounds), which failed before this branch too. Working around them inside visx would hide a framework defect behind an app workaround.xychart/components/series/private(19),tooltip/floating(15),brush(11),zoom(10).SOURCE_PUBLICATION_DEBTcomment records visx at// 57 errors. Measured on main under the current toolchain it is 158. The recorded counts look like they were taken through a pipe, which truncates. Not touched here, since entries are deleted rather than edited.Provenance
agent-authored)Note
Medium Risk
Broad public TypeScript surface change in visx (handlers and className semantics) with no runtime change; consumers on strict checking may need prop/handler updates. SWR changes are test-harness only.
Overview
@octanejs/visx moves forty-two modules from React
SVGPropstoOctane.SVGPropsso consumers compiling published source stop hitting assignability errors (native DOM handlers, clsx-styleclassName, optionalidwhereuseStableIdapplies). Runtime behavior and export names stay the same; public prop types change for SVG rest props and nested bags (tickLabelProps,glyphStyle, etc.).Supporting fixes: hierarchy/network dynamic components use capitalized JSX instead of
createElement;TooltipPositionConsumeris a small render-prop wrapper overuseContext;d3-interpolate-pathgets a module declaration;AnimatedPathdrops a stale@ts-expect-error.tests/types/parity.test-d.tsgains recursive normalization for attribute bags (flat spreads, nested members, render-prop arguments) plus per-component carve-outs so upstream parity checks still pass without key-only pins for most surfaces.SWR pristine Jest harness now gates a second
useSWRrace (local mutation /isValidating:true) the same way as the existing remote-mutation case, with docs, manifest hashes, and a unit test for the timer gate.Reviewed by Cursor Bugbot for commit 64fbb78. Bugbot is set up for automated code reviews on this repo. Configure here.