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
Type for Color
missing string[]
for indexable options
#9461
Comments
I'm not sure the definitely typed versions are correct. According to their types, the following is valid but it is won't be parsed correctly by https://github.com/kurkle/color. const dataset = {
pointBackgroundColor: [
['red', 'green'],
['blue', 'yellow']
]
} Are you able to provide a full example showing how this format is used? I tested in using the latest dev code and the colours were not correctly applied |
@etimberg I'm not sure that is correct. The DefinitelyTyped version allowed for an array of strings like so:
Which according to the Chart.js docs is an indexable option. This worked fine in v2 using the DefinitelyTyped type definitions. Now fails in v3 using the built-in type definitions. |
That is supported in v3 as well using. The definitely typed versions say that I just tested locally in our TS tests (using ts 4.3.5) and there were no errors. What TS version are you using? const chart = new Chart('id', {
type: 'line',
data: {
labels: [],
datasets: [{
data: [],
pointBackgroundColor: ['red', 'green'],
}]
},
}); |
That PR hasn't been released yet, so v3.4.1 would only work as far as TS v4.1.x. This should be resolved once 3.5.0 releases |
If your chart type is |
@etimberg Ahh. I see. I'll keep my eye out for 3.5 then. Thanks for the quick reply and awesome work on this project! |
@kurkle I was using the |
3.5.0 is released so this should be working now |
Expected Behavior
The
Color
type should support indexable options.Current Behavior
The Typescript compiler will return the following error when providing an array of strings for an indexable color property (e.g.
pointBackgroundColor
):Possible Solution
Update the
Color
type definition to include an option forstring[]
, as was previously done with DefinitleyTypedThe text was updated successfully, but these errors were encountered: