Skip to content

Type definition of LegendItem does not correspond to actual data #10319

@julianegoe

Description

@julianegoe

Expected behavior

When using TypeScript the LegendItem in my example is supposed to have a structure of
`{
text: string;

fillStyle: string;

strokeStyle: string;

lineWidth: number;

hidden: boolean,

index: number
}`

Current behavior

But in the type definitions of chart.js the index is missing and replaced by datasetIndex: Relevant File

Reproducible sample

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENYBo4BkCmA5vgHYAmAkjPiHAL5wBmUEtA5AMYawB0AVgGc2AbgCwAKAkA3THA4wAHnAC8cMhA4BXEKRg9iMAKIAbGroBCATwpkAFACIQltJhj2AlHHQC4ACQAqALK4yOgkMgImZiQwYuIyUHBOLrAqcCT4AO4o3DC28go4CBJwpXAwlmD4AFxwbOqahKgkmjBsWCVlZOgw6LXF4mVDcMboAEb4xgK1ANr2AEr4ZPY49ubGmvgrcPYAmpPGEJnb9gDiUPikJwAKmlBgpicA8lBhxPYAuh2Dw6XdvQJ8DBpnAZgNfr9RhNjLU2ABiOAQRhwABqEGoQm+EOG-z6oIAjAAmHD4gCcOAAzDgAKw4YlwClfTq-OgfZn0LFlCBgGDACAkEHg4YPRrAAX9dlDUzEcgSn7YqGTQWSiGaQHXCBimAAZQqplqMCgm052NKjGAxmoUFqtmlpEo1BAtQIModNE8ygAfIgVdiOPyBBBTDxDoRbUR7VR3XFTcMLjA7iQRhHyFGQDwxWR8EoADxwQm+4Z0E0QuiFsvy+gSOjuYRAA

Optional extra steps/info to reproduce

No response

Possible solution

Change the TypeDefinition to include the index

Context

I'm using Vue 3 with Typescript and my code editor throws an error.

chart.js version

v3.7.1

Browser name and version

Chrome 100.0.4896.127

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