resend / react-email

💌 Build and send emails using React
https://react.email
MIT License
14.16k stars 645 forks source link

Could not find a declaration file for module #1234

Closed raskyer closed 2 months ago

raskyer commented 8 months ago

Describe the Bug

When I run npm run tsc

> tsc

node_modules/@react-email/code-block/dist/index.d.mts:3:19 - error TS7016: Could not find a declaration file for module 'prismjs'. '/node_modules/prismjs/prism.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prismjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'prismjs';`

3 import Prism from 'prismjs';
                    ~~~~~~~~~

node_modules/@react-email/render/dist/index.d.mts:1:55 - error TS7016: Could not find a declaration file for module 'html-to-text'. '/node_modules/html-to-text/lib/html-to-text.mjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/html-to-text` if it exists or add a new declaration (.d.ts) file containing `declare module 'html-to-text';`

1 import { HtmlToTextOptions, SelectorDefinition } from 'html-to-text';
                                                        ~~~~~~~~~~~~~~

node_modules/@react-email/tailwind/dist/tailwind.d.ts:2:55 - error TS2307: Cannot find module 'tailwindcss' or its corresponding type declarations.

2 import type { Config as TailwindOriginalConfig } from "tailwindcss";
                                                        ~~~~~~~~~~~~~

Found 3 errors in 3 files.

Errors  Files
     1  node_modules/@react-email/code-block/dist/index.d.mts:3
     1  node_modules/@react-email/render/dist/index.d.mts:1
     1  node_modules/@react-email/tailwind/dist/tailwind.d.ts:2

Which package is affected (leave empty if unsure)

No response

Link to the code that reproduces this issue

NA

To Reproduce

Expected Behavior

No error

What's your node version? (if relevant)

^0.0.12

gabrielmfern commented 8 months ago

Can you give a reproduction of this?

hydrielax commented 8 months ago

I have the same problem here. To reproduce:

After investigating, I think this is because some types from @types/prismjs, @types/html-to-text, and @types/tailwindcss are exported in the packages @react-email/code-block, @react-email/render and @react-email/tailwind, but the@types/... dependencies are defined in the devDependencies instead of the dependencies for each of these packages, so they are not available for type-checking on a custom project.

gabrielmfern commented 8 months ago

Got a reproduction of something like this after messing around for a bit, do you all have "skipLibCheck": false or don't have it defined at all?

hydrielax commented 7 months ago

skipLibCheck is not defined at all on my side (so defaulting to false I think)

rossanodr commented 4 months ago

did you manage to fix it? I'm facing the same issue

renatoastra commented 3 months ago

Same problema here!

gabrielmfern commented 2 months ago

Anyone having this issue, add "skipLibCheck": true to your ts config and it should be fine. Not an issue on React Email's side at all. Closing as not planned.