]> git.ipfire.org Git - thirdparty/Chart.js.git/commit
Fix helpers `Chart` type (#12012)
authorJosh Kelley <joshkel@gmail.com>
Thu, 30 Jan 2025 09:29:19 +0000 (04:29 -0500)
committerGitHub <noreply@github.com>
Thu, 30 Jan 2025 09:29:19 +0000 (10:29 +0100)
commit370f6c385d648ab52f576824b9a22453fa4648f1
tree67f6ed3e1c39078afa16141a1224b7b107af221d
parentf744621c9c6ed331d6fe81ac9744fa72bdb0700d
Fix helpers `Chart` type (#12012)

helpers.dom.ts functions referenced the internal `Chart` JavaScript class rather than the published `Chart<TType, TData, TLabel>` TypeScript definition. This causes errors when outside code tries to call helper functions.

The two `Chart` interfaces are incompatible - the `width`, `height`, and `currentDevicePixelRatio` properties are declared as readonly in the TS declaration but are manipulated by helpers.dom.ts functions, and helpers.dom.ts functions need to be invoked both by internal Chart.js code (which uses the JS class) and by outside code (which uses the TS types). To address this, I'm importing the JS version as `PrivateChart`. There may be a better solution.

It's my understanding that the comment about "typedefs are auto-exported" is obsolete now that helpers.dom is a native TS file.

Fixes #11153
src/helpers/helpers.dom.ts
test/types/helpers/dom.ts [new file with mode: 0644]