question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Type definition for ChartOptions

See original GitHub issue

Current and expected behavior

I posted this issue in chart.js repo, but I think it is related to this lib and its type definitions.

With these options,

const options = {
    scales: {
      y: {
        min: 0,
      },
      x: {
        type: 'time', // << ts error
      ...

I got this error:

Type ‘string’ is not assignable to type ‘“timeseries” | undefined’.

So, I added as any (not ideal):

type: ‘time’ as any,

If there is a more correct way, I’d love to know.

Here’s my reproduction:

https://github.com/JBaczuk/chartjs-9085-repro

image

Reproduction

https://github.com/JBaczuk/chartjs-9085-repro

chart.js version

v3.7.0

react-chartjs-2 version

v4.0.0

Possible solution

unsure

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
dangreencommented, Jan 31, 2022

@JBaczuk More stable variant is define type of options explicitly:

import {
  ChartOptions
} from "chart.js";

const options: ChartOptions<"line"> = { /* ... */ };
1reaction
dangreencommented, Jan 27, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Kendo, TypeScript definition bug: - Stack Overflow
When I do this, I get the following error, which seems to indicate that ChartOptions is expected to be an array: "Error 70...
Read more >
Bug Types (Summary) - Test IO Academy
A bug is a software-related problem. If something on a website or in an application does not work as intended, this “error” is...
Read more >
Highcharts TypeScript Declarations (beta)
Reporting Bugs# ... The TypeScript declarations for Highcharts are in a beta state. They can be used in production, but we can't guarantee...
Read more >
Animations | Chart.js
Animation configuration consists of 3 keys. Name, Type, Details. animation, object, animation. animations, object, animations.
Read more >
Reporting defects in Agile Development 2.0 - ServiceNow Docs
Define a new planning item type in Alignment Planner Workspace ... Create a task from an incident, problem, or change request ... Gantt...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found