victory icon indicating copy to clipboard operation
victory copied to clipboard

Data Accessors using a function gives Typescript compiling errors

Open jacovanwijk opened this issue 2 years ago • 0 comments

Bug Reports

Checklist

  • [x] I have read through the FAQ and Guides

  • [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

Since version 3.5.* using the Data Accessors on either bar or line using a function gives Typescript compiling errors. It think the following commit caused the issue: https://github.com/FormidableLabs/victory/commit/43baeadb734bcb6c03e9abb4806fbe625f49ea4e#diff-066d807c91e06b799cde9263f3800161e2382910e1f5e259fd8c8a35eab1ba63R14

Changing object to any would fix the error, although you probably want to avoid any.

Reproduction

Sandbox https://codesandbox.io/s/victory-brush-zoom-chart-forked-ucmswz?file=/src/components/Chart.tsx

jacovanwijk avatar Jul 12 '22 13:07 jacovanwijk

I think, at this point, using any is the best bet.
We don't (yet) support generics on our components (eg. where we could infer the data type and use that for the datum parameter). And we don't know anything about the shape of datum.

So it makes sense to type as any, which would also allow the consumer to explicitly specify their own type.

scottrippey avatar Aug 19 '22 06:08 scottrippey

Published as 36.6.4! Thanks for reporting!

scottrippey avatar Aug 19 '22 18:08 scottrippey