Error in npm package - how to squelch?
I'm using an npm package that I think isn't being processed for Deno correctly.
I get this error:
I can
deno run
it and it works fine. But is there a way to remove the error from my editor?
Here's a minimal code example. I'm using Deno 1.41.3.
1 Reply
The error you're encountering suggests that the npm package
sitemapper
may not be providing the correct types for Deno's module resolution, specifically the node16
resolution that Deno supports. According to the documentation, many NPM packages fail to correctly provide types under node16
module resolution, which can result in deno check
reporting type errors that the TypeScript compiler tsc
does not report.
To address this issue in your editor, you have a few options:
1. Open an issue at the issue tracker of the sitemapper
package about the problem. You could also contribute a fix if you're able to.
2. Use a CDN that rebuilds the packages for Deno support, instead of an npm:
identifier.
3. Ignore the type errors in your codebase with // @ts-expect-error
or // @ts-ignore
.
For your specific case, you could try adding // @ts-expect-error
above the line where you're getting the error to suppress it in your editor:
This tells TypeScript to expect an error on the next line and not report it. However, use this with caution as it suppresses the error message, which might hide actual issues with the code.
Remember that using // @ts-expect-error
or // @ts-ignore
is more of a workaround than a solution. If possible, it's better to address the underlying issue with the package's type definitions. 🦕