Skip to content

Breaking change syncing TypeScript declarations with their implementations - #3689

Open
PaulHax wants to merge 3 commits into
major-38from
typescript-types-sync
Open

PaulHax wants to merge 3 commits into
major-38from
typescript-types-sync

Conversation

@PaulHax

@PaulHax PaulHax commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Context

Bring the published TypeScript declarations into sync with the JavaScript implementation. Downstream projects currently need local declarations for missing modules and corrections for inaccurate signatures.

Results

Declarations cover hundreds more modules and describe their runtime exports, accessors, factory options, and static APIs more accurately. Consumers can remove overlapping local declare module '@kitware/vtk.js/...' shims. Corrected signatures can require call-site updates for nullability, typed arrays, and renderer-specific view APIs.

This PR changes declaration files, their validation configs, and migration documentation. Runtime behavior is unchanged.

Downstream

  • VolView: Kitware/VolView#928 removes 310 lines of local @kitware/vtk.js declarations.
  • cornerstone3D: vtk-types-compat types custom render-pass locals and removes an invokeEvent suppression.

Changes

  • Add missing declarations and correct member signatures, return types, nullability, newInstance options, and static exports.
  • Infer typed-array factory results from constructor names, including the Float64Array fallback for optional BigInt constructors.
  • Share an ES2020 and DOM baseline across source, ESM, and UMD declaration checks. Consumers using an older TypeScript lib list should add ES2020.BigInt; their target can stay unchanged.
  • Match current rendering APIs, including WebGPU storage buffers, texture ownership, mipmaps, multisampling, material properties, and resource release.
  • Correct widget event ownership and animation options to match the objects that implement them.
  • Type setXFrom and setters without a return value as void, and include null or undefined where accessors can return them.
  • Remove named value exports that only exist on a module's default export. Import constants such as DesiredOutputPrecision, VtkDataTypes, BoundaryCondition, and PolygonWithPointIntersectionState from their module's Constants entry point.
  • Make vtkPolygon.PolygonIntersectionState a type alias of PolygonWithPointIntersectionState; the old enum values did not match the runtime constants. Use the constants module for runtime values.

PR Checklist

  • GitHub Actions CI passed
  • Documentation and TypeScript definitions are updated to match these changes

Testing

No runtime tests are added because runtime behavior is unchanged. The companion declaration conformance work covers declaration and consumer contracts separately; runtime fixes remain outside this PR.

Supersedes #3617. This branch lives in Kitware/vtk-js so dependent PRs can target it.

@PaulHax
PaulHax force-pushed the typescript-types-sync branch from 31f7fc3 to a32dfd4 Compare October 19, 2026 20:43
@PaulHax
PaulHax added this pull request to stack #3695 October 19, 2026 20:46
@PaulHax
PaulHax removed this pull request from stack #3695 October 19, 2026 21:01
@PaulHax
PaulHax added this pull request to stack #3696 October 19, 2026 21:01

@finetjul finetjul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PaulHax
PaulHax force-pushed the typescript-types-sync branch from a32dfd4 to 3bcb493 Compare October 22, 2026 16:09
The hand-maintained .d.ts files have accumulated gaps and inaccuracies.

Some downstream projects carry local declaration shims to cover missing entry points.

Add declarations for previously untyped modules and correct known issues in existing declarations.

The changes were derived from macro definitions, implementation exports, and the built ESM output.

BREAKING CHANGE: TypeScript builds that compiled against the previous declarations may now fail.

Runtime behavior is unchanged. Consumers should remove overlapping local declaration shims.

Code may need updates for corrected return types, nullability, exports, and constants.
BREAKING CHANGE: Listener and proxy operations now declare void returns.
CellPicker and WebXR setters declare boolean returns, and box intersections
and view rotations require numeric inputs. MatrixBuilder factories return
transformation instances without construct signatures.
@PaulHax
PaulHax force-pushed the typescript-types-sync branch from 3bcb493 to 2ca8378 Compare October 22, 2026 16:28

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants