victory icon indicating copy to clipboard operation
victory copied to clipboard

Typescript 5.2.2 issue in VictoryLineBase

Open wadehammes opened this issue 2 years ago • 3 comments

Describe the bug image

Code in question:

        <VictoryLine
          data={Array.from(electricCostsByYear).map(([year, cost]) => ({
            x: year,
            y: cost,
          }))}
          style={{
            data: {
              stroke: CHART_COLORS[0],
              strokeWidth: ({ active }) => (active ? 6 : 4),
              strokeDasharray: "12",
            },
            labels: { fill: CHART_COLORS[0] },
          }}
        />

Victory version Latest

Code Sandbox link

To Reproduce Steps to reproduce the behavior:

  1. Use Victory Line Chart with TS 5.2.2

Expected behavior No error like in previous version of TS

Screenshots Above

wadehammes avatar Aug 25 '23 14:08 wadehammes

@wadehammes Seeing the same issue after bumping TypeScript to 5.2.2 in a Next.js project.

Not ideal, but for anyone hitting the same issue and needs a quick fix... explicitly declaring active as an optional boolean worked for me.

strokeWidth: ({ active }: { active?: boolean }) => (active ? 6 : 4)

klmoot avatar Aug 30 '23 11:08 klmoot

@wadehammes Seeing the same issue after bumping TypeScript to 5.2.2 in a Next.js project.

Not ideal, but for anyone hitting the same issue and needs a quick fix... explicitly declaring active as an optional boolean worked for me.

strokeWidth: ({ active }: { active?: boolean }) => (active ? 6 : 4)

This worked for me. Thanks!

wadehammes avatar Aug 30 '23 13:08 wadehammes

We are working on updating all components to full TS and getting on the latest version. Will revisit this when Victory is on TS 5.x

carbonrobot avatar Jan 17 '24 17:01 carbonrobot