Skip to content

Breaking change syncing TypeScript declarations with their implementations - #3617

Closed
PaulHax wants to merge 1 commit into
Kitware:masterfrom
PaulHax:typescript-types-sync
Closed

PaulHax wants to merge 1 commit into
Kitware:masterfrom
PaulHax:typescript-types-sync

Conversation

@PaulHax

@PaulHax PaulHax commented Aug 28, 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.

Superseded by #3689, which uses a Kitware/vtk-js branch and targets major-38.

@PaulHax
PaulHax requested a review from daker August 28, 2026 02:41
@PaulHax PaulHax changed the title Breakikng change syncing TypeScript declarations with their implementations Breaking change syncing TypeScript declarations with their implementations Aug 28, 2026
@PaulHax
PaulHax force-pushed the typescript-types-sync branch from c64bb85 to 4883512 Compare August 28, 2026 02:45

@daker daker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM i didn't run a check to validate all +500 files

@PaulHax
PaulHax force-pushed the typescript-types-sync branch 2 times, most recently from 0273758 to a73487e Compare September 23, 2026 17:47
@PaulHax
PaulHax force-pushed the typescript-types-sync branch 3 times, most recently from aadd4b8 to 1cbd570 Compare October 19, 2026 13:49
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.
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