TypeScript: Plugin interface doesn't accept TData and TLabel generic arguments from Chart
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Expected behavior
```ts
export interface Plugin, TLabel = unknown, O = AnyObject> extends ExtendedPlugin {
afterDatasetsDraw?(chart: Chart, args: EmptyObject, options: O, cancelable: false): void;
}
```
### Current behavior
```ts
export interface Plugin extends ExtendedPlugin {
afterDatasetsDraw?(chart: Chart, args: EmptyObject, options: O, cancelable: false): void;
}
```
### Reproducible sample
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENYBoUdgEXRnQGcBTGHABQBsBXAc2ADs4BfOAMyghDgHIAxnhgA6AFYl+AbgCwAKAUwAnmDJwAsssLE4AXjhQy6ACYRmNZXADazOiABGZKDhIwoLBgF05i+YPM3OBBtIlIKAC5cTBgdcJgAHn4zRlQ7GH4cLTiAPn1EBTg4EzCo6wBGACYAZhx+TggIfi8FNl8FAOYgkNpGFijepmYklIY0ugy8gwRCuAB6ObhUZ3VgEjh0OBU1ODWSOjIcJ0F0OnI4QZZZ9E4YZzjyWKh0AHcogAphGKi0GJGIVLpTKaULEHIASn0eRm8iKRU6QWsgjoUCMzFiYUeJC8+S+sFEJWIBMxFBIvjhcAR8GsIQAcvYnC5gsoAMruTw4gzI1FkdEPUnE4jk9itXxAA
### Optional extra steps/info to reproduce
```ts
import { Chart, ChartDataset, Plugin } from 'chart.js';
type MyData = readonly [number, string];
const myDataset: ChartDataset<'doughnut', MyData> = {
data: [123, 'foo']
};
const myPlugin: Plugin<'doughnut'> = {
// here is a type issue, because of Plugin doesn't accept TData
afterDatasetDraw: (chart: Chart<'doughnut', MyData>) => {
const [currentDatasets] = chart.data.datasets;
const [myNumber, myString] = currentDatasets.data;
}
};
```
### Possible solution
apply suggestion from `Expected behavior` above
### Context
_No response_
### chart.js version
4.4.1
### 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.