Given a library (let's call it LibraryA) that uses another library without typing - particularly js-yaml. To do so LibraryA has a devDependency @types/js-yam
in its package.json
. LibraryA itself compiles just fine.
Now I have a project where I installed LibraryA as a dependency (in devDependencies). In that project I imported types from the LibraryA and so that LibraryA gets compiled by tsc when I compile the whole project.
But tsc reports an error about code in LibraryA where I import js-yaml (import yaml from 'js-yaml'
):
error TS7016: Could not find a declaration file for module 'js-yaml'.
I checked the node_modules for the project, and there's no @types/js-yaml there. So, it explains why tsc can't see the typings. But I can't understand why it wasn't installed in the first place (when I installed LibraryA).
project
package.json
devDependencies
LibraryA
LibraryA
package.json
dependencies
"js-yaml": "^4.1.0",
devDependencies
"@types/js-yaml": "^4.0.5",
js-yaml
So, probably the question is about npm and why it doesn't install "@types/js-yaml inside the project.