This directory documents the TypeScript conversion in progress.
| Doc | Audience |
|---|---|
| SETUP.md | First-time contributor — toolchain overview, npm scripts |
| ARCHITECTURE.md | Anyone working with types — directory layout, public/private split |
| CONVERTING_ATTRIBUTES.md | Contributor doing conversion work — step-by-step recipe |
| GENERATOR.md | Maintainer extending or debugging the type generator |
- TypeScript build infrastructure: ✅ done
- Public type surface in
src/types/: ✅ done AttributeMapvalidation machinery: ✅ done- Schema-based type generator: ✅ done — all trace types + layout + shared interfaces
- Consumer entry point (
lib/index.d.ts, wired viapackage.json#types): ✅ done - CI gates (
typecheck+schema-typegen-diff-check): ✅ done - First attribute file converted (modebar): ✅ done
- Conversion of remaining files: 🚧 in progress
-
src/fonts/ploticon.js— convert soDefaultIconsandIconsMapinsrc/types/core/api.d.tscan be derived from the module (type DefaultIcons = keyof typeof Ploticon) instead of maintained as a hand-written union that can drift. Consumers need.defaultappended per the established conversion pattern. -
Add dimensionality to
data_arrayin the JS attribute sources. The schema'sdata_arrayvalType carries no shape info, but several attributes are genuinely 2D (heatmap/contour/contourcarpetz, surfacezandsurfacecolor, 2Dtext/customdata/hovertexton those traces) or 3D (image.z). The generator currently emits the loose unionDatum[] | Datum[][] | TypedArrayfor everydata_arrayso 2D/3D usage typechecks, but the trade-off is that 1D-only fields also accept 2D arrays.
The published consumer surface lives at lib/index.d.ts.
This src/types/ directory is the authoring location — internal types live
here, public types are re-exported through lib/index.d.ts to consumers.
The following are auto-generated from plot-schema.json by
tasks/generate_schema_types.mjs:
- Common enum aliases (Calendar, Dash, AxisType, PatternShape, XRef, YRef,
TransitionEasing, TraceType — and a deprecated
PlotTypealias) - Data interfaces for each trace type (BarData, ScatterData, IndicatorData, etc.)
and the
Datadiscriminated union over all of them - Layout component interfaces (LayoutAxis, Legend, Scene, Annotation, Shape, Slider, UpdateMenu, etc.) and the Layout interface itself
- Shared sub-interfaces (Font, ColorBar, HoverLabel, LegendGroupTitle, etc.)
- Animation / frame / edits interfaces (AnimationOpts, Frame, Edits)
- An
_internalnamespace with helpers like_internal.Marker,_internal.AutoRangeOptionsthat aren't meant as direct public surface
Run npm run schema to regenerate. The output lives at
src/types/generated/schema.d.ts. See GENERATOR.md for
the generator's internals.
If you want to convert a component attribute file:
- Read CONVERTING_ATTRIBUTES.md
- Pick a component file from the priority list at the bottom of that doc
- Claim it in a PR description
- Follow the recipe
- Submit a PR
Each conversion is a single self-contained commit.