Reputation: 9103
Is there a way to configure npm
in such a way so that whenever I install a package, it will:
@types/PACKAGE
with the --save-dev
flagIdeally, 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
).
Upvotes: 4
Views: 2752
Reputation: 29829
Here are some command line utilities that help with this
Install missing TypeScript typings for dependencies in your package.json
Easily install new packages and their types, every time.
A small utility for installing TypeScript definition files using npm
Upvotes: 5
Reputation: 5264
I ended up writing a CLI utility that does exactly this. Thin layer on top of your package manager of choice.
Check it out at https://github.com/xavdid/typed-install
Upvotes: 1