Type error setting pointStype to false
- 主要语言
- JavaScript
- 星标
- 67.7k
- 派生
- 11.9k
- 平均合并
- 7 小时 39 分钟
- 30 天内合并 PR
- 5
描述
### Expected behavior
I hope I can define a dataset with a boolean pointStyle without getting a typing error
### Current behavior
When i add the following config:
```typescript
new Chart(canvas, {
type: 'line',
data: {
labels: generateLabels(),
datasets: [
{
label: 'Dataset',
data: generateData(),
pointStyle: false, <--
},
],
}
```
I get the following typing error
_Type '{ pointStyle: boolean; }' is not assignable to type 'ChartDatasetCustomTypesPerDataset<"line", number[]>'._
### Reproducible sample
https://codesandbox.io/s/ng2charts-chart-js-issue-template-forked-r5kcm4
Updated example: https://codesandbox.io/s/ng2charts-chart-js-issue-template-forked-6fd62d?file=/src/app/app.component.ts
(does not complain about the boolean type, but neither does it complain about an invalid string type)
### Optional extra steps/info to reproduce
_No response_
### Possible solution
It is currently "fixed" by forcing a type as shown here
`pointStyle: false as unknown as string,`
but I wouldn't want to have to do this.
### Context
I am working on Angular 16
### chart.js version
4.3.0
### Browser name and version
Firefox Developer Edition 115.0b9 (64-bit) on Ubuntu
### Link to your project
_No response_
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 Chart.js 的折线图 TypeScript dataset 配置开始,追踪 pointStyle 属性声明的类型。使用更新后的 CodeSandbox 验证 false 会被接受,而无效字符串仍会被拒绝;在不使用 workaround 的情况下解决报告的类型错误即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, typescript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100