Skip to content

Breaking change syncing TypeScript declarations with their implementations - #3617

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

Breaking change syncing TypeScript declarations with their implementations#3617
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 most of the published TypeScript surface back in sync with the JavaScript implementation.

Results

Every module under Sources now has a declaration, and every declared member exists on the implementation — .d.ts files under Sources: 287 → 540.

No runtime file is touched. This PR changes .d.ts files, package.json, and BREAKING_CHANGES.md only. Consumers can remove local declare module '@kitware/vtk.js/...' shims.

Downstream

  • VolViewKitware/VolView#928 deletes src/shims-vtk.d.ts, 310 lines of local @kitware/vtk.js stubs.
  • cornerstone3Dvtk-types-compat types the custom render-pass locals and drops an invokeEvent suppression.

Changes

  • 253 declarations added for modules that shipped none, and 246 corrected to match their implementation: member surface, accessor return types, nullability, newInstance option types, and static exports.

  • Accessors: setXFrom and setters that only return; are now void, not boolean. Accessors that can read back null/undefined say so, and fields absent from DEFAULT_VALUES are T | undefined rather than Nullable<T>.

  • Named exports reachable only through a module's default export are no longer declared. Importing them by name never resolved at runtime. DesiredOutputPrecision, VtkDataTypes, BoundaryCondition, and PolygonWithPointIntersectionState come from <Module>/Constants.

  • vtkPolygon: PolygonIntersectionState was off by one against the runtime constant (FAILURE is -1, not 0). It is now an alias of PolygonWithPointIntersectionState and cannot be used in value position.

  • package.json: adds @webgpu/types, required by the WebGPU declarations.

  • Documentation and TypeScript definitions were updated to match those changes

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

No unit tests added because there are no runtime changes. The declarations are verified with npm run typecheck; formatting is verified with npm run validate.

For additional validation context, the internal fork has companion PRs for the declaration conformance scripts and the runtime bug fixes uncovered by the declaration work.

@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
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.
@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

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