9

I tried to import my test module installing with npm i github.com/.../... and the codes, it's working properly, but in VSCode it has something like this:

Could not find a declaration file for module 'estrajs'. 'C:/Users/Users/Desktop/Test/TestFolder/node_modules/mymodule/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/mymodule` if it exists or add a new declaration (.d.ts) file containing `declare module 'mymodule';`ts(7016)

How do I make the declaration of it? I already make file on typings/index.d.ts

1
  • make sure to include your type definitions root in tsconfig, also try to restart TS server in VS Code, you can see what I'm doing in github.com/Maxim-Mazurok/google-api-typings-generator with typings folder for example, but otherwise there are not enough details to answer Commented Jan 21, 2022 at 6:32

2 Answers 2

16

Ah I figured out, I simply just type on index.d.ts file

declare module 'mymodule';
Sign up to request clarification or add additional context in comments.

Comments

4

try to add the following to the tsconfig.json file

"noImplicitAny": false

3 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
I'm using Nx with react and this actually worked for me. what I did was adding "noImplicitAny": false to tsconfig.base.json. the error I had was Could not find a declaration file for module 'pagedjs'. '/node_modules/pagedjs/src/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/pagedjs if it exists or add a new declaration (.d.ts) file containing declare module 'pagedjs`
I was struggling with the error for hours, but this one solved the problem. Thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.