This question has been asked and answered many different ways on Stack overflow and I think I've tried them all. This question is specific to getting it to work using @nrwl/nx.
The specific error is
TS7016: Could not find a declaration file for module 'libxmljs2-xsd'. '/Users/xyz/hpxml-gen/node_modules/libxmljs2-xsd/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/libxmljs2-xsd` if it exists or add a new declaration (.d.ts) file containing `declare module 'libxmljs2-xsd';`
I've tried unsuccessfully:
- Creating a global.d.ts file with
declare module 'libxmljs2-xsd'
in it. - Create index.d.ts file with
declare module 'libxmljs2-xsd'
and tried putting it at the root of the Nx lib, insidesrc
and insidesrc/lib
. None of those locations worked. - Modifying tsconfig.lib.json inside the root dir:
"include": ["**/*.ts", "**/*.d.ts"]
. I've also tried"include": ["**/*.ts", "index.d.ts"]
- Created
types/index.d.ts
at root and in the root tsconfig.base.json added"typeRoots": ["node_modules/@types", "./types"]
I realize I can set "noImplicitAny": false
but don't want to do that and lose a lot of the value of typescript.
I've spent a day on this thinking there has to be something simple I'm missing. I've searched stack overflow, all of the GitHub tickets and their documentation. Does anyone know how this works in Nx?