Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error ToastContainer after running tsc in command line #561

Closed
achmadk opened this issue Jan 29, 2021 · 9 comments · Fixed by newerton/gobarber-frontend#11 or newerton/gostack-modulo07#17
Labels

Comments

@achmadk
Copy link

achmadk commented Jan 29, 2021

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
After upgrading react-toastify to v7.0.2, I execute tsc in command line. Unfortunately I got error message like this:

node_modules/react-toastify/dist/components/index.d.ts:3:15 - error TS2307: Cannot find module './ToastContainer' or its corresponding type declarations.

3 export * from './ToastContainer';
                ~~~~~~~~~~~~~~~~~~

node_modules/react-toastify/dist/index.d.ts:3:10 - error TS2305: Module '"./components"' has no exported member 'ToastContainer'.

3 export { ToastContainer, Bounce, Flip, Slide, Zoom } from './components';

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:

  1. Create web app template with react and typescript
  2. Import ToastContainer component, then use it into your app.
  3. Check typescript checking with command tsc

What is the expected behavior?
No error emit after execute tsc.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
I am using react v17 and ubuntu OS.

achmadk added a commit to achmadk/react-toastify that referenced this issue Jan 29, 2021
use export default `ToastContainer` from '/src/components/ToastContainer.tsx' files, then recreate variable `ToastContainer` in `src/components/index.tsx` instead.

fix fkhadra#561
achmadk added a commit to achmadk/react-toastify that referenced this issue Jan 29, 2021
fix typos from 'Optionnal' to 'Optional'. add more values on `type` props

fix fkhadra#561
@achmadk
Copy link
Author

achmadk commented Jan 29, 2021

If you dont mind, please check here to resolve this issue.

@fkhadra
Copy link
Owner

fkhadra commented Jan 29, 2021

Hello @achmadk,

I think that something is wrong with your setup. I've been using the library exclusively with typescript and I never had this issue.
You can find below a working example with typescript using CRA
Edit relaxed-shadow-nwcn4

Maybe if you can share your tsconfig.json or reproduce the issue using codesanbox I could help.

@achmadk
Copy link
Author

achmadk commented Jan 29, 2021

I have refresh install dependencies with yarn but still have same problem above.

Edit holy-cache-dddx8

Glecun added a commit to Glecun/soundboard that referenced this issue Jan 31, 2021
If skipLibCheck is false, "tsc" is fired on librairies and it fails because a class ToastContainer is not present in react-toastify.

$ yarn tsc
node_modules/react-toastify/dist/components/index.d.ts:3:15 - error TS2307: Cannot find module './ToastContainer' or its corresponding type declarations.

Issue related: fkhadra/react-toastify#561
Glecun added a commit to Glecun/soundboard that referenced this issue Feb 1, 2021
If skipLibCheck is false, "tsc" is fired on librairies and it fails because a class ToastContainer is not present in react-toastify.

$ yarn tsc
node_modules/react-toastify/dist/components/index.d.ts:3:15 - error TS2307: Cannot find module './ToastContainer' or its corresponding type declarations.

Issue related: fkhadra/react-toastify#561
@felixmosh
Copy link

felixmosh commented Feb 1, 2021

same in my projects, the ToastContainer.d.ts is missing in node_modules,
(using yarn 1)

image

@fkhadra
Copy link
Owner

fkhadra commented Feb 1, 2021

Thanks, @felixmosh that was helpful. TBH I don't even know how this happened. I've built it again and published a new version to npm.

@felixmosh
Copy link

@fkhadra I've just tested 7.0.3, same issue :|

@fkhadra
Copy link
Owner

fkhadra commented Feb 1, 2021

@felixmosh can you delete node_modules/react-toastify ?
I've tried again on my side and I can see the typescript defintion
Screen Shot 2021-02-01 at 1 04 45 PM

Also, it has been packed when I ran npm publish
Screen Shot 2021-02-01 at 1 05 38 PM

@felixmosh
Copy link

Yeap, that helped, Thanx for the quick fix

@fkhadra
Copy link
Owner

fkhadra commented Feb 1, 2021

@felixmosh you're welcome. cc @achmadk

achmadk added a commit to achmadk/react-toastify that referenced this issue Feb 1, 2021
use export default `ToastContainer` from '/src/components/ToastContainer.tsx' files, then recreate variable `ToastContainer` in `src/components/index.tsx` instead.

fix fkhadra#561
achmadk added a commit to achmadk/react-toastify that referenced this issue Feb 1, 2021
fix typos from 'Optionnal' to 'Optional'. add more values on `type` props

fix fkhadra#561
achmadk added a commit to achmadk/react-toastify that referenced this issue Feb 1, 2021
use default import instead of `ToastContainer` to fix error testing

fix fkhadra#561
@fkhadra fkhadra closed this as completed Feb 1, 2021
Glecun added a commit to Glecun/soundboard that referenced this issue Feb 3, 2021
Glecun added a commit to Glecun/soundboard that referenced this issue Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants