Skip to content

TypeScript: chartHelpers.getRelativePosition(new Event(''), new Chart()) doesn't pass #11153

@cyantree

Description

@cyantree

Expected behavior

When passing a Chart instance to the helper method getRelativePosition() I expect the types to be correct. In v3 this worked.

Current behavior

The types don't match and the following error will be shown:

const chart: Chart<"bar", number[], string>
Argument of type 'Chart<"bar", number[], string>' is not assignable to parameter of type 'Chart'.
  Type 'Chart<"bar", number[], string>' is missing the following properties from type 'Chart': _options, _aspectRatio, _layers, _metasets, and 41 more.ts(2345)

Reproducible sample

https://codesandbox.io/s/typescript-playground-export-forked-ufm45w?file=/index.ts:435-491

Optional extra steps/info to reproduce

Open the sandbox, ignore the runtime error and just look at the TS compiler error.

Possible solution

No response

Context

No response

chart.js version

v4.2.1

Browser name and version

No response

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions