Semantic-ui-react: Accordion: onTitleClick typings are incorrect

Created on 22 Feb 2018  路  9Comments  路  Source: Semantic-Org/Semantic-UI-React

Steps

Use Accordion's onTitleClick property according to the typings, which look like this

onTitleClick?: (event: React.MouseEvent<HTMLDivElement>, index: number | number[]) => void;

Expected Result

get a number or number[] as the second argument

Actual Result

got an object

Version

0.78.2

Testcase

https://codesandbox.io/s/vjzyjjqr13

bug

All 9 comments

馃憢 Thanks for opening your first issue here! If you're reporting a 馃悶 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

Can you update your codesandbox? It does not have any Accordion component on it

Sorry, I guess I forgot to save the sandbox! I'll update the description.

Cool. I'm not too familiar with TypeScript, but it's weird that on AccordionAccordion.js, onTitleClick is documented this way:
/** * Called when a panel title is clicked. * * @param {SyntheticEvent} event - React's original SyntheticEvent. * @param {object} data - All item props. */
This seems to be what's happening, as data's type in your code example is an object with the element's information.

the problem is that the type declared in the .d.ts file is incorrect and no longer matches the actual behavior. The code was changed without the typing being updated.

Makes sense, maybe the maintainers should know a little bit more about this

Thanks for report, will be fixed by #2568.

@layershifter it looks like there are a good number of TypeScript errors with this project. Any talk of converting the source code to TypeScript and generating the type definitions instead, so they're never out of sync?

This project will be never converted to TS as we have really huge codebase there. If you have issues with typings, fill free to open PR with fixes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

levithomason picture levithomason  路  39Comments

skleeschulte picture skleeschulte  路  22Comments

layershifter picture layershifter  路  32Comments

anhdle14 picture anhdle14  路  20Comments

levithomason picture levithomason  路  24Comments