FormidableLabs / victory

A collection of composable React components for building interactive data visualizations
http://commerce.nearform.com/open-source/victory/
Other
10.98k stars 525 forks source link

Type Error in Victory Container 36.9.1 #2815

Open carbonrobot opened 7 months ago

carbonrobot commented 7 months ago

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

KenanYusuf commented 7 months ago

The types for this function have been rewritten here #2799

eatyourpeas commented 7 months ago

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.

napmn commented 7 months ago

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
>