Skip to content

fix: give the plugin geometry its own non-nullable Point - #970

Merged
kurkle merged 1 commit into
chartjs:masterfrom
kurkle:fix-chartjs-451-types
Sep 17, 2026
Merged

kurkle merged 1 commit into
chartjs:masterfrom
kurkle:fix-chartjs-451-types

Conversation

@kurkle

@kurkle kurkle commented Sep 17, 2026

Copy link
Copy Markdown
Member

Chart.js 4.5 widened Point to { x: number | null; y: number | null } so it can also describe a gap in a dataset. The plugin used that same type for canvas geometry, so bumping the dev dependency to 4.5.1 (#962) fails to compile with 15 errors across core, gestures, handlers, scale.types and utils.

Every one of those is a zoom centre, a drag corner, a pan delta or a hit test position -- a real coordinate that is never null. Rather than null check values that cannot be null, Point is now declared in src/types.ts and the geometry imports it from there. Chart.js keeps being imported for everything else.

This also tightens the public API in the right direction: passing a Chart.js Point, which may now hold nulls, into chart.zoomRect() or chart.pan() no longer type checks, and it would have misbehaved at runtime.

Compiles and passes the browser tests against both 4.4.8 and 4.5.1, so #962 should go green once it is rebased on this.

Chart.js 4.5 widened Point to `{ x: number | null; y: number | null }` so it
can also describe a gap in a dataset. The plugin used that same type for
canvas geometry, so bumping the dev dependency to 4.5.1 (chartjs#962) fails to
compile with 15 errors across core, gestures, handlers, scale.types and utils.

Every one of those is a zoom centre, a drag corner, a pan delta or a hit test
position -- a real coordinate that is never null. Rather than null check values
that cannot be null, Point is now declared in src/types.ts and the geometry
imports it from there. Chart.js keeps being imported for everything else.

This also tightens the public API in the right direction: passing a Chart.js
Point, which may now hold nulls, into chart.zoomRect() or chart.pan() no
longer type checks, and it would have misbehaved at runtime.

Compiles and passes the browser tests against both 4.4.8 and 4.5.1, so chartjs#962
should go green once it is rebased on this.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kurkle kurkle added the types label Sep 17, 2026
@kurkle
kurkle merged commit 88f9878 into chartjs:master Sep 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant