fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.33k stars 676 forks source link

CloseButton type definition is wrong #971

Open thejayhaykid opened 1 year ago

thejayhaykid commented 1 year ago

Do you want to request a feature or report a bug? Bug 🐛

What is the current behavior? The compiled TypeScript definitions for the CloseButton end up as React.JSX.Element which isn't actually a type

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

Adding this package to a project, looking in node_modules/react-toastify/dist/components/CloseButton.d.ts(9,96) shows this:

export declare function CloseButton({ closeToast, theme, ariaLabel }: CloseButtonProps): React.JSX.Element;

Which outputs this error:

node_modules/react-toastify/dist/components/CloseButton.d.ts(9,96): error TS2694: Namespace 'React' has no exported member 'JSX'.

What is the expected behavior? It should explicitly list the expected return type of the CloseButton function, guessing based on what other components are, it should be React.ReactElement

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? It is not working when trying to publish an internal NPM package that uses this package within it.

Brumor commented 1 year ago

@thejayhaykid had the same issue and it ended up being that the new version of the package is using react 18 and my project is still on 17 so i had to downgrade toastify to 8.2.0

thejayhaykid commented 1 year ago

Thanks @Brumor, that got me to look into the versions and I found that I was using react 18 and @types/react 17, updating that got rid of the error.

But the close button should still have an explicit return to prevent issues from occurring