victory icon indicating copy to clipboard operation
victory copied to clipboard

Type Error in Victory Container 36.9.1

Open carbonrobot opened this issue 1 year ago • 3 comments

I am using victory 36.9.1 and react 18.2 in node 20

It is all working in production currently on node 16, react 17 using victory 35.4.8

I am trying to create a voronoi zoom container

import { VictoryVoronoiContainerProps } from 'victory-voronoi-container';
import { VictoryZoomContainerProps } from 'victory-zoom-container';

When I create the container I get a type error:

const VictoryZoomVoronoiContainer = createContainer<VictoryZoomContainerProps, VictoryVoronoiContainerProps>(
    'zoom',
    'voronoi',
);
Expected 0 type arguments, but got 2.ts(2558)

Apologies in advance if this is my fault and is a question best directed elsewhere.

Originally posted by @eatyourpeas in https://github.com/FormidableLabs/victory/issues/1446#issuecomment-1950179439

carbonrobot avatar Feb 18 '24 16:02 carbonrobot

The types for this function have been rewritten here #2799

KenanYusuf avatar Feb 19 '24 14:02 KenanYusuf

In fact I managed to get this working in the end with this (note, breaks without the any):

// allows two top level containers: zoom and voronoi
const VictoryZoomVoronoiContainer:any = createContainer(
    'zoom',
    'voronoi',
);

Feels like I have not understood the types magic that is going on here, but this works for me for the moment, unless there is some better way I should do this.

eatyourpeas avatar Feb 20 '24 11:02 eatyourpeas

to get the same type as before the change that broke this you can temporarily use

const VictoryZoomVoronoiContainer = createContainer('zoom', 'voronoi') as React.ComponentType<
  VictoryVoronoiContainerProps & VictoryZoomContainerProps
>

napmn avatar Mar 04 '24 12:03 napmn