visx icon indicating copy to clipboard operation
visx copied to clipboard

[docs] typescript doc generator missing extended/base types

Open Stuhl opened this issue 3 years ago • 3 comments

Either I'm blind or there is documentation missing.

This is part of the code from the Area example: https://airbnb.io/visx/areas

<Bar
x={margin.left}
y={margin.top}
width={innerWidth}
height={innerHeight}
fill="transparent"
rx={14}
onTouchStart={handleTooltip}
onTouchMove={handleTooltip}
onMouseMove={handleTooltip}
onMouseLeave={() => hideTooltip()}
/>

However navigating to the "Bar" shape documentation (https://airbnb.io/visx/docs/shape#Bar) shows this:

<Bar />
# classNamestring | undefined
className to apply to rect element.

# innerRef((instance: SVGRectElement | null) => void) | RefObject<SVGRectElement> | null | undefined
reference to rect element.

I probably missed something, I guess it's inheriting from a base shape but I can't find it. Would appreciate any help :)

Stuhl avatar Sep 21 '21 16:09 Stuhl

Looks like our typescript doc generator doesn't follow the extended types which are defined here: https://github.com/airbnb/visx/blob/master/packages/visx-shape/src/shapes/Bar.tsx#L16

The additional props are the standard SVGRectElement attributes. Anything you can pass to <rect /> you can pass to <Bar />. In hindsight, I should have just named it <Rect /> instead of <Bar />. Oh well.

hshoff avatar Dec 22 '21 21:12 hshoff

Thanks for answering @hshoff, it all makes sense now.

The thing is that alot of people (including me) are beginners in charting with low level primitives and almost never use SVG attributes. It's 100% our fault to not know that and it's not your responsibility to remind us but it would be a better user experience for beginners if you would make a short note about the SVG attributes.

Kinda like "These are the props inherited by our base class while the others are standard SVG attributes and events. See this for reference."

Where "this" would be a link to MDN or similar.

Stuhl avatar Dec 25 '21 19:12 Stuhl

@Stuhl it's a bug on our part. Our typescript doc generator should follow the extended types and include them in the documentation. Going to reopen this issue and use it for tracking the documentation bug. Thanks for reporting!

hshoff avatar Dec 29 '21 18:12 hshoff