Skip to content

Mismatching type for pointSymbol from ResponsiveLine #2818

@macabeus

Description

@macabeus

Describe/explain the bug

The type for the pointSymbol prop from ResponsiveLine<T> is wrong.
Example:

type ChartDatum = {
  x: string;
  y: number;
  stalled: boolean;
};

type ChartSeries = {
  id: string;
  data: readonly ChartDatum[];
};

// ...

return (
  <ResponsiveLine<ChartSeries>
    pointSymbol={({ datum, size, borderWidth }) => {
      // @ts-expect-error
      console.log('Stalled data is at:', datum.stalled); // datum.stalled -> any
      console.log('But the typing thinks it is at:', datum.data?.stalled); // datum.data?.stalled -> boolean

      return (
        <circle
          r={size / 2}
          fill="#0e7490"
          stroke="#22d3ee"
          strokeWidth={borderWidth} />
      );
    }}

To Reproduce

Steps to reproduce the behavior:

  1. git clone git@github.com:macabeus/mizuchi.git
  2. git checkout a7365f5
  3. Check the as never on src/report-generator/ui/components/AttemptsChart.tsx

Expected behavior
No as never should be necessary to type this code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions