Skip to content

How to disable 'Could not find a declaration file for module' #142

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
raxod502 opened this issue Feb 14, 2020 · 6 comments
Closed

How to disable 'Could not find a declaration file for module' #142

raxod502 opened this issue Feb 14, 2020 · 6 comments

Comments

@raxod502
Copy link

I have a JavaScript file which includes

import "regenerator-runtime/runtime";

and this gets a warning from the language server

typescript: Could not find a declaration file for module 'regenerator-runtime/runtime'.
'<filename>' implicitly has an 'any' type
Try `npm install @types/regenerator-runtime` if it exists or add a new declaration (.d.ts) file
containing `declare module 'regenerator-runtime/runtime';` [7016]

This is not a useful warning because my code is not TypeScript and I do not care about types. How can I disable the warning? Here's what I already tried:

  • Create a file types.d.ts next to my index.js containing declare module '*'; (I use Parcel to compile my webapp)
  • Create a tsconfig.json in my project root with { "compilerOptions": { "noImplicitAny": false } }
  • Install type definitions just to make the server happy -- unfortunately none exist
  • Add to line before the import // @ts-ignore

None of these do anything, even after I restart the language server. How do I disable the warning?

@avegancafe
Copy link

I'm also having trouble with this. @raxod502 did you ever find a solution?

@raxod502
Copy link
Author

I am looking at that line of code in my project right now, and currently no warning is being displayed. However, I cannot for the life of me figure out why that might be. Here is the code, though, in case it is helpful.

@jangid
Copy link

jangid commented Jun 7, 2021

I am also have the same problem. Is there a fix for this?

@HannaNguyen-new
Copy link

I have the same problem. I don't use typescript but when i require skipper the warning appears.
const skipper = require('skipper-better-s3')

Would appreciate any solution to this.

@b0o
Copy link

b0o commented Oct 28, 2021

Same issue here in a JS-only project that uses tsserver for LSP. I've tried all of the supposed solutions I can find and none of them seem to have any effect. Looking through the logs, I've verified that tsserver is indeed seeing my .d.ts file and my tsconfig.json files.

@rchl
Copy link
Member

rchl commented Nov 14, 2021

It will be possible to ignore specific diagnostics with the new diagnostics.ignoredCodes option in the next release.

@rchl rchl closed this as completed Nov 14, 2021
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

6 participants