chartjs / chartjs/Chart.js

Chart data type is incorrect in 4.1.2

Open
#11,064 8 comments 0 reactions 0 assignees View on GitHub
type: bug type: types
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

The types for the Chart object has `data: ChartData`, but it should be `data: ChartData;` instead to have the dataset typed properly within the data. Otherwise it's the default types from `DefaultDataPoint`

```
export declare class Chart<
TType extends ChartType = ChartType,
TData = DefaultDataPoint,
TLabel = unknown
> {
// ...
data: ChartData;
// ...
```

### Current behavior

```
export declare class Chart<
TType extends ChartType = ChartType,
TData = DefaultDataPoint,
TLabel = unknown
> {
// ...
data: ChartData;
// ...
```

### Reproducible sample

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGzAJ5gCmK6MHgHNonAGroANgFc+AXkRs4cMgOGiAXHDowowAHZCWrZQDcpsrfukgARjyjHlZCJOgB+LTr2Hj2NhzcfGiYMAAqQXAKIbAAPABEkgY88QA0-IIiUOIWPADaALoAfAGsAPRlcAByEDDAZHxhqHwAIgLoEbxwACYQPHT6JPAYpnwwzXBcvHRwYISmwN083fiExDHhQYFdbTAdkdGUm7x5JN3tJAWMQA

### Optional extra steps/info to reproduce

_No response_

### Possible solution

_No response_

### Context

_No response_

### chart.js version

4.1.2

### Browser name and version

_No response_

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.