$ tsc
main.ts:1:24 - error TS7016: Could not find a declaration file for module 'ngrok'. '.../node_modules/ngrok/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ngrok` if it exists or add a new declaration (.d.ts) file containing `declare module 'ngrok';`
1 import * as ngrok from 'ngrok';
~~~~~~~
Found 1 error in main.ts:1
Additional context
My intent in this example is to import ngrok using require, and this is what's happening, but typescript doesn't seem to pick up the .d.ts file.
Typescripts esm support is not without controversies. One of them is that they are more strict about the location of .d.ts files: https://github.com/microsoft/TypeScript/issues/49160 . The most straightforward solution seems to be renaming ngrok.d.ts to index.d.ts, but there might be better ways I am not aware of.
Describe the bug
Getting
when trying to import in a project with
moduleResolution: node16
.To Reproduce
package.json
tsconfig.json
main.ts
and then run:
Output I get:
Additional context
My intent in this example is to import ngrok using require, and this is what's happening, but typescript doesn't seem to pick up the
.d.ts
file.Typescripts esm support is not without controversies. One of them is that they are more strict about the location of
.d.ts
files: https://github.com/microsoft/TypeScript/issues/49160 . The most straightforward solution seems to be renamingngrok.d.ts
toindex.d.ts
, but there might be better ways I am not aware of.