Victory: Typescript Support: maintain our own typings

Created on 26 Jun 2018  路  14Comments  路  Source: FormidableLabs/victory

Bugs and Questions

Checklist

  • [x] This is not a victory-native specific issue. (Issues that only appear in victory-native should be opened here)

  • [x] I have read through the FAQ and Guides before asking a question

  • [x] I am using the latest version of Victory

  • [x] I've searched open issues to make sure I'm not opening a duplicate issue

The Problem

When using typescript and importing VictoryZoomContainer and VictoryBrushContainer I get the following errors

[ts] Module '"victory"' has no exported member 'VictoryZoomContainer'
[ts] Module '"victory"' has no exported member 'VictoryBrushContainer'

Reproduction

I tried reproducing the issue in sandbox but the error only sometimes appears. I am not sure why, but here is the sandbox anyway
https://codesandbox.io/s/94jn2qzylo

I have also created a git repo which contains the issue.
https://github.com/StraightOuttaCrompton/victory-typescript-example

Steps to replicate -
npm install
npm start

Should produce a compiler error in App.tsx stating "Module '"victory"' has no exported member 'VictoryZoomContainer'."

All 14 comments

@StraightOuttaCrompton I'm sorry, we don't publish typescript typings for Victory, but instead rely on the community. I would guess that the typings are out of date. I will change the title of this issue.

Is there someone in the community I can contact about it? Or is it possible I can try and resolve it myself?

You could reach out to the contributors or make a PR here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/victory/index.d.ts

We will likely bring these types under our maintenance umbrella in the coming months. Sorry for the trouble in the meantime.

Ok, that's brilliant. Thank you for your hard work!

I am facing the same issue with VictoryVoronoiContainer and VictoryTooltip.

I tried working around this by defining the typings in my local index.d.ts file for @types/victory. But, that doesn't seem to fix the issue. Is there a workaround to this or do I simply have to wait for the typings file to be updated?

You'll have to make a pull request as @boygirl has suggested and edit the typings to make it work or wait until they start maintaining their own typings. I am planning on making a pull request at some point if I get time.

@redixhumayun I've been pushing some PRs to update the types to the DefinitelyTyped repo, including a full VictoryTooltip interface that it was missing. There are a lot of issues in the current types that I've had to fix, the biggest I've encountered was ToolTips missing and I think VictoryTheme type is completely out of date.

This PR has solved the issue I was originally having
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/27048

It seems that it is not recommended to include typings in your package when it is not written in typescript. Instead typings should be maintained on DefinitelyTyped. https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

.. or write Victory in typescript and everyone wins ;)

I've recently run into this issue attempting to use VictoryCandlestick which appears to be missing from the DefinitelyTyped definitions.

@boygirl Before I consider writing a PR, is anyone currently working on this?

@JayTurn sorry for the delay. This is not currently in progress

I made a couple of upstream changes to the types as well, but I will also mention that Victory's cloneElement heavy approach makes typing difficult. Props that take a component "instance" rather than just the component error on the missing props that are provided by Victory later. I'm open to upstreaming any fixes that solve this but I'm not sure how to approach besides just making everything optional, which doesn't feel right. Any ideas?

I know this is backlogged but it has also been over a year since update. I have made an addition to @types/victory to add in missing props but they have also pointed out that victory has started exporting types. So I was wondering what the overall status is of type in victory.

@JeffBaumgardt apologies. This issue should be closed now. We recently completed a thorough audit of our types. I'm sure there are still places they could be improved, but they should be pretty complete at this point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

icd2k3 picture icd2k3  路  3Comments

tgoldenberg picture tgoldenberg  路  5Comments

nickzuber picture nickzuber  路  5Comments

devth picture devth  路  4Comments

AndresTIY picture AndresTIY  路  5Comments