Skip to content

In React: Could not find a declaration file for module '@tailwindcss/forms' #18

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

Closed
instanetk opened this issue Nov 28, 2020 · 4 comments

Comments

@instanetk
Copy link

Followed the install instructions

npm install @tailwindcss/forms

Then required the plugin in tailwind.config.js

// tailwind.config.js

module.exports = { // ... plugins: [ require('@tailwindcss/forms'), ] }

But when mousing over the @tailwindcss/forms the following message is displayed:

module "/Users/user/Desktop/Index/git/project/react/node_modules/@tailwindcss/forms/src/index" Could not find a declaration file for module '@tailwindcss/forms'. '/Users/user/Desktop/Index/git/project/react/node_modules/@tailwindcss/forms/src/index.js' implicitly has an 'any' type. Try npm install @types/tailwindcss__formsif it exists or add a new declaration (.d.ts) file containingdeclare module '@tailwindcss/forms';ts(7016)

So far no joy...

PS: I was previously using custom-forms with the same error. Opened an issue with the same content under that project. Sorry if it is cross posting but I am experiencing the same issue with both packages...

@instanetk
Copy link
Author

Because I was following along the Workcation tutorial on YouTube, I was attempting to use Forms as Custom-Forms.

Perhaps there could be an onboarding for those like me who were in the Custom-Forms mindset.

I solved the issue above by adding a global.d.ts to my root directory with the following line declare module '@tailwindcss/forms';

Also, this post from Tailwind's blog would be helpful to understand the context of this project: https://blog.tailwindcss.com/tailwindcss-v2#utility-friendly-form-styles

Hope it helps someone new to Tailwind like myself! 🙂

@liam-ot
Copy link

liam-ot commented Apr 3, 2021

Your wish has come true, it just helped me a lot. Had exact same issue, started with custom-forms and everything and found your other post lol

This happened to me in a Vue environment so not specific to react

Just wondering if anyone knows, this error went away following the instruction @instanetk but my tailwind-intellisense in vscode still does not recommend any form classes, why is that? I assume it is because that intellisense is not up to date with the new forms plugin?

also with forms installed on my server it was rendering the forms classes added without trouble, why is this declaration file needed in local dev env and not on the server to work?

thanks!

@gregrobsonoxb
Copy link

Thank you @instanetk I was trying to import @tailwindcss/aspect-ratio - I applied that fix and it builds perfectly now.

@Amir3599
Copy link

Amir3599 commented May 21, 2022

how to add global.d.ts file to react with plain javascript?
this doesn't work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants