How to declare typings included in library in tsconfig?

251 Views Asked by At

I get the following message in VSCode.:

Could not find a declaration file for module 'LIBRARY'. '...node_modules/LIBRARY/lib/FILENAME.js' implicitly has an 'any' type. Try npm install @types/LIBRARY if it exists or add a new declaration (.d.ts) file containing declare module 'LIBRARY';ts(7016)

I have declared a (.d.ts) file in the typings folder in node_modules/LIBRARY/.

Also I use LocalForage as a dependency in my LIBRARY. LocalForage brings their own typings in node_modules/localforage/typings/ localforage.d.ts, which can also not be found.

I tried the following in the tsconfig.json:

{
.
.
.
    "types": [
      "**/*.d.ts",
      "./node_modules/localforage/typings/localforage.d.ts",
      "./node_modules/LIBRARY/typings/FILENAME.d.ts",
    ],
    "typeRoots": [
      "./node_modules/*/typings",
      "./node_modules/**/typings",
      "./node_modules/@types"
    ],
.
.
.
}

but it does not work.

How can I setup it in the tsconfig file, so that Typescript can find it?

0

There are 0 best solutions below