Skip to content

Undocumented (and maybe unwanted) breaking changes in 3.0.0-beta.11 #8470

Description

@jnizet

Expected Behavior

These lines of Typescript code, which compiled fine in 3.0.0-beta.10, should also compile in beta.11 (I haven't found any documented breaking change documenting those):

  const chartOptions: ChartConfiguration<'bar'> = {
      type: 'bar',
      // irrelevant properties omitted
      options: {
        plugins: {
          tooltip: {
            callbacks: {
              // error here because dataPoint doesn't exist anymore
              label: context => context.dataset.label + ': ' + formatNumber(context.dataPoint.y)
            }
          }
        },
        scales: {
          y: {
            ticks: {
              // error here because the tick value is now typed as unknown
              callback: (value: number) => formatNumber(value)
            }
          }
        }
      }
    };

Current Behavior

They don't compile anymore.

Possible Solution

I've had to change them to

  const chartOptions: ChartConfiguration<'bar'> = {
      type: 'bar',
      // irrelevant properties omitted
      options: {
        plugins: {
          tooltip: {
            callbacks: {
              label: context =>
                context.dataset.label +
                ': ' +
                formatNumber(context.dataset.data[context.dataIndex] as number)
                // dataPoint was easier to use than the above, and its `y` value was typed as number, whereas context.dataset.data[context.dataIndex] as number is typed as unknown
            }
          }
        },
        scales: {
          y: {
            ticks: {
              callback: (value) => formatNumber(value as number)
            }
          }
        }
      }
    };

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions