I have been developing a TypeScript NPM package by following instructions from this tutorial
You can check out the code here
After publishing the NPM package, it is available here
Installation of the package is simple using
npm install loglevel-file-logger
To use it in a TypeScript project, just import like this
import setupLogger from 'loglevel-file-logger'
Everything works smoothly. However, when trying to import a non-index file from the package such as
import FetchBlobWriter from 'loglevel-file-logger/FetchBlobWriter'
TypeScript gives an error
[ts] Cannot find module 'loglevel-file-logger/FetchBlobWriter'.
If you look into the compiled JS code, you will notice that the typing file for FetchBlobWriter
does exist at js/FetchBlobWriter.d.ts
Any thoughts on why TypeScript is unable to locate the module even though the .d.ts
file is present?