Skip to content

@octanejs/recharts is unusable under a strict consumer typecheck #726

Closed

Description

@dudusotero

Corrected 2026-08-12. The original body attributed most of the TS2307 to the untyped .js modules and did not list Cause 4. Neither is right: none of the TS2307 comes from .js. See the correction comment for the measurement.

This is split out from #721, which covers the same class of failure across jotai, redux, remix-router, and visx. recharts is filed separately because the volume is an order of magnitude larger and two of the three causes are specific to this package.

Summary

@octanejs/recharts publishes raw source ("files": ["src"], "exports": { ".": "./src/index.ts" }), so a consumer's TypeScript program compiles every reachable file in the package. Under the tsconfig our own CLI scaffolds, that produces 1507 errors. The package cannot be consumed by a strict TypeScript app.

Reproduction

Any app that imports @octanejs/recharts and runs tsrx-tsc --noEmit with the tsconfig from packages/cli/src/commands/init/templates.js. Within the monorepo, pointing that same tsconfig shape at packages/recharts/src reproduces it.

Error breakdown, consumer tsconfig:

Code Count Meaning
TS7016 421 no declaration file for an imported .js module
TS7006 367 parameter implicitly any
TS2305 254 module has no exported member
TS2307 148 cannot find module
TS7031 86 binding element implicitly any
TS2694 68 namespace has no exported member

Against the package's own tsconfig.json, still with tsrx-tsc, it is 1268 errors across 94 files. The current pnpm typecheck runs tsgo here instead, which ignores .tsrx entirely and exits 0.

Cause 1: 123 untyped .js modules are published

packages/recharts/src contains 123 .js files. None has a sibling .d.ts. The package's own tsconfig sets "allowJs": true, "checkJs": false, so they resolve locally. The scaffolded consumer tsconfig sets neither, so every import of one is an error. This accounts for the 421 TS7016.

It also produces errors that look unrelated. ./easing resolves to easing.js, so CSSTransitionAnimate.tsrx(11,10) reports that EasingInput and NamedBezier are not exported. The actual cause is that the module carries no types at all.

Cause 2: 16 published src/*.ts files are excluded from the package's own typecheck

packages/recharts/tsconfig.json excludes these, all of which exist and all of which ship in the tarball:

src/chart/types.ts
src/context/useTooltipAxis.ts
src/state/selectors/{area,funnel,pie,polarGrid,polarScale,polar,radar,radialBar,scatter}Selectors.ts
src/util/cursor/{getCursorPoints,getCursorRectangle,getRadialCursorPoints}.ts
src/util/scale/CartesianScaleHelper.ts
src/util/tooltip/translate.ts

exclude only filters the expansion of include. It does not remove files reached through the import graph, so consumers compile all 16 regardless. The package's own check is green because it skips 16 files that consumers cannot skip.

Cause 3: ./AnimationController does not exist

src/animation/CSSTransitionAnimate.tsrx:12
  import type { AnimationController } from './AnimationController';

src/animation/ contains AnimationControllerImpl.js and no AnimationController. This one is independent of tsconfig and fails under any configuration.

Separately, CSSTransitionAnimate.tsrx(2,10) imports CSSProperties from octane, which does not export it.

Cause 4: 177 extensionless imports of .tsrx modules

147 TS2307 total
  133  the specifier resolves to an existing sibling .tsrx
    0  resolves to a .js
    0  resolves to a .ts
   14  genuinely does not exist

None of the TS2307 come from the .js modules. With allowJs off, importing a .js gives TS7016, not TS2307. The 133 are extensionless relative imports of .tsrx modules, for example import { Rectangle } from './shape/Rectangle' where only shape/Rectangle.tsrx exists. tsrx-tsc does not complete an extensionless specifier to .tsrx the way it does to .ts.

Counting extensionless relative imports whose only resolution is a sibling .tsrx, across every packages/*/src: recharts 177, every other package 0. Every other binding writes the extension.

The port leaned on this deliberately, and on something real. packages/octane/src/compiler/vite.js adds .tsrx to Vite's resolver extensions, commented as required so extensionless imports of octane components resolve exactly like React's .tsx. The bundler supports it on purpose; the typechecker does not. No consumer-side tsconfig bridges the gap: paths, allowArbitraryExtensions and a .tsrx.d.ts sidecar all still produce TS2307.

Suggested fix

  1. Fix the broken ./AnimationController import and the CSSProperties import.
  2. Add the explicit .tsrx extension at the 177 extensionless sites. 46 distinct target modules, none with a .ts, .tsx or .d.ts sibling, so a codemod is unambiguous. Eight sites sit in vendored .ts files where the edit diverges from upstream and need the port owner's call.
  3. Give the 123 .js modules real types, either by converting them to .ts or by shipping generated .d.ts alongside them. Converting is preferable, because a published .d.ts can drift from the .js it describes.
  4. Remove the 16 src/ entries from exclude and fix what they surface. Consumers compile these files either way, so leaving them excluded here only hides the errors from us.
  5. Drop allowJs/checkJs from the package tsconfig once step 2 lands, so the package's config stops being more permissive than the consumer's.
  6. Type the component props behind the 367 TS7006 and 86 TS7031. This is the one part shared with Several published TSRX source bindings fail strict consumer tsrx-tsc typechecking #721.
  7. Add @octanejs/recharts to PACKED_TSRX_CONSUMER_PACKAGES so this cannot regress, including the no-@types/node variant discussed in Several published TSRX source bindings fail strict consumer tsrx-tsc typechecking #721.

Steps 1 through 4 come before step 5 is worth doing: while the .js modules are untyped, a large share of the remaining diagnostics are downstream of missing types rather than genuine signal.

Activity

  1. dudusotero commented on Aug 12, 2026

    @dudusotero
    ContributorAuthor

    Correcting a claim in the issue body before this gets closed by #733.

    Cause 1 says the untyped .js modules account for "the 421 TS7016 and most of the TS2307". The TS7016 half holds. The TS2307 half is wrong, and it points at the wrong fix.

    I resolved every TS2307 specifier against the filesystem:

    147 TS2307 total
      133  the specifier resolves to an existing sibling .tsrx
        0  resolves to a .js
        0  resolves to a .ts
       14  genuinely does not exist
    

    So none of the TS2307 come from the .js modules. With allowJs off, importing a .js produces TS7016, not TS2307. The 133 are extensionless relative imports of .tsrx modules, for example import { Rectangle } from './shape/Rectangle' where only shape/Rectangle.tsrx exists. tsrx-tsc does not complete an extensionless specifier to .tsrx the way it does to .ts.

    This is a fourth cause the issue did not list, and it is specific to this package. Counting extensionless relative imports whose only resolution is a sibling .tsrx, across every packages/*/src in the repo:

    recharts   177
    all others   0
    

    Every other binding writes the extension explicitly. packages/recharts/docs-adjacent notes in docs/recharts-port-plan.md record the choice to mirror upstream's layout "so upstream relative imports resolve unchanged", with Bar.ts and Line.ts described as extensionless-resolution shims, so the port leaned on this deliberately.

    It leaned on something real. packages/octane/src/compiler/vite.js adds .tsrx to Vite's resolver extension list, with a comment stating that extensionless imports of octane components must resolve exactly like React's .tsx, because faithful ports keep upstream's extensionless dynamic imports. So the bundler supports this on purpose and the typechecker does not. I could not find a consumer-side tsconfig that bridges it; paths, allowArbitraryExtensions, and a .tsrx.d.ts sidecar on the target all still produce TS2307.

    Two consequences for the fix:

    The mechanical part is 177 sites across 49 files, targeting 46 distinct modules. None of the 46 has a .ts, .tsx or .d.ts sibling, so .tsrx is the unambiguous completion at every site and a codemod is safe. Eight sites are in vendored .ts files where the extension edit would diverge from upstream, and those need the port owner's call.

    The toolchain asymmetry deserves its own issue regardless of what happens to recharts, or the next faithful port repeats this.

    Separately: #730 routes types at src/index.d.ts, and #733 absorbs it. That stops consumers compiling the internal graph, so it resolves the consumer-facing symptom without touching any of the four causes. Worth noting that packages/recharts has no scripts entry of its own, while packages/visx/scripts/check-public-types.mjs exists precisely to stop a hand-written declaration surface drifting from the real one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions