You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the docs, null values are allowed for skipped values for Line Charts. The following code should pass the type check:
import{Chart}from'chart.js';varctx=document.getElementById("myChart")asHTMLCanvasElement;varmyChart=newChart<'line'>(ctx,{// Config example from documentationtype: 'line',data: {datasets: [{data: [{x: 10,y: 20},{x: 15,y: null},{x: 20,y: 10}]// ~~~~ null value here, should be ok}]}});
Current behavior
TypeScript error: Type 'null' is not assignable to type 'number'.
Expected behavior
According to the docs,
null
values are allowed for skipped values for Line Charts. The following code should pass the type check:Current behavior
TypeScript error:
Type 'null' is not assignable to type 'number'.
Reproducible sample
https://www.typescriptlang.org/play/?ssl=11&ssc=4&pln=10&pc=4#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGwG6ZxkwAecALxwAJhDIBXEAFMAdjCoBzaTACiAG2kz5AIQCeASREAKAEQg9aTDFMBKOOjpwAEgBUAsgBlk6WVzoaWnIwLKxcUHAWVljCstIA7iiUMAA8JOrAcSQAfMa8fAA0iGxwcDB6YNIAXKQZWQUlougw6DUIjaUizY4qdDUA2u2spSNNLQMIfDUAjAAMRXo1AEyz2EWTMwCsCzWyEurqa4hTcCs7cHPYALodODfDOGzYtoxAA
Optional extra steps/info to reproduce
Generic type should be specified for Chart constructor:
new Chart<'line'>(...)
. There are no errors without it.Possible solution
No response
Context
No response
chart.js version
v4.4.7
Browser name and version
No response
Link to your project
No response
The text was updated successfully, but these errors were encountered: