New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v3-beta][types] fix a wrong Option infer #7770
Conversation
Rebased. I'll explain a little later why there is a bug. |
I think I follow what this is doing. @sgratzl thoughts as well? |
Only possible issue that comes to mind, is mixed charts: const chart = new Chart(ctx, {
type: 'bar',
data: {
datasets: [
{data: [1, 2, 3]},
{type: 'line', data: [3, 2, 1]}
]
}
}); Not quite sure if it is a problem, but I hope @xr0master can spot the issue if it exists :) |
looks good to me |
@kurkle in very short, the issue is about the wrong position. |
I just now realized what the issue is in this example. |
So, if we want to strict types, we can do it like this: const barChart = new Chart<number, string, IBarControllerConfiguration>(node, {
type: 'bar',
data: {
datasets: [{
type: 'bar',
data: [],
}]
},
options,
plugins,
}); BTW @emmcbd FYI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one does not really have anything to do with the mixed chart issue, so that can be solved separately.
Yes, of course, I just noticed. To be honest, I'm not sure if there is an issue at all with mixed charts. |
The issue is that "infer O" takes type from the Dataset type instead of Options.
It should be:
However we cannot set the
unknown
type for the dataset becauseunknown
cannot be IChartDataset. Then I thought, why do we need to use anunknown
type for no-need types? We can use the type definition everywhere and only return the type we need. Let me know what do you think about it.