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

Could not find a declaration file for module #1234

Open
raskyer opened this issue Jan 23, 2024 · 5 comments
Open

Could not find a declaration file for module #1234

raskyer opened this issue Jan 23, 2024 · 5 comments

Comments

@raskyer
Copy link

raskyer commented Jan 23, 2024

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

  • Install @react-email/render in typescript project
  • Run tsc to check typescript types validity

Expected Behavior

No error

What's your node version? (if relevant)

^0.0.12

@raskyer raskyer added the Type: Bug Confirmed bug label Jan 23, 2024
@gabrielmfern
Copy link
Collaborator

Can you give a reproduction of this?

@hydrielax
Copy link

I have the same problem here. To reproduce:

  • create a new react-email project
  • create an email file in .tsx
  • run a typecheck on your project (tsx)
  • the typecheck fails

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
Copy link
Collaborator

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
Copy link

hydrielax commented Feb 26, 2024

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

@rossanodr
Copy link

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

  • Install @react-email/render in typescript project
  • Run tsc to check typescript types validity

Expected Behavior

No error

What's your node version? (if relevant)

^0.0.12

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

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

No branches or pull requests

4 participants