Too complex union type when combining TooltipModel with Vue ref
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
## Expected Behavior
You should be able to use the `TooltipModel` type in combination with Vue refs without type issues.
## Current Behavior
You get a "Expression produces a union type that is too complex to represent." error in version 3.5.1 and above. 3.5.0 and below works.
## Possible Solution
I'm guessing the change that introduced the issue was https://github.com/chartjs/Chart.js/pull/9490, though. Possibly because it made `TooltipModel` recursive (TooltipModel -> TooltipItem -> Chart -> TooltipModel)? But to be honest I'm not quite sure if this is something that should be fixed on Chart.js' end, Vue's end or even Typescript's end. If you don't feel like it should be fixed here then feel free to close this (but if you have a suggestion for who to pass the buck to in that case that would be appreciated).
## Steps to Reproduce
https://stackblitz.com/edit/vitejs-vite-ynfase?file=src%2Fmain.ts&terminal=dev
You'll have to wait for a while, but eventually Typescript gives up evaluating and the `foo.value` will be marked with the error I mentioned.
Note that the `{} as ...` stuff is just to simplify the example so I don't have to type out a full actual `TooltipModel`, the result is the same either way.
## Context
I'm storing a `TooltipModel` in a Vue ref because I'm using a Vue component to create a custom tooltip. It's probably possible for me to work around this issue but perhaps not with full type safety intact, which would be a bit of a shame.
## Environment
* Chart.js version: 3.6.2 for the example, but in general 3.5.1+ exhibits the issue
* Browser name and version: Chromium 96
* Link to your project: My actual project isn't public, but I've made a local reproduction equivalent to the online one: https://github.com/henribru/chart-js-too-complex-union-type-repro
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.