Is there a way to configure npm
in such a way so that whenever I install a package, it will:
- Check if it has type definitions inside it
- If it does not, try to install
@types/PACKAGE
with the--save-dev
flag
Ideally, I'd like this to happen automatically (as a plugin or something) without writing a shell script that will limit the API. For example, I might write a shell script such as: (note that this doesn't really answer all the requirements)
#!/bin/bash
npm install --save $1 && npm install --save-dev @types/$1
But this limits me because maybe I want to --save-dev
both of the packages or want to use some special flags in the command. Also, it creates a dependency on bash which I'd like to avoid.
Alternatively, if there is a way to make a shellscript that won't be limiting in that way, that would be okay too.
Also, the above example doesn't actually check if the package has type definitions already (in which case I don't want to download any from @types
).