flow-typed
is a CLI tool that provides auto-discovery of flow type definitions for installed JS packages (and other things).
I usually use TypeScript over Flow and often find myself installing packages like this:
yarn add lodash express bluebird
yarn add --dev @types/lodash @types/express @types/bluebird
I recently stumbled on to flow-typed
and its install
command, which checks the installed packages and automatically installs the type definitions for them, as required.
With flow-typed
I would simply do:
yarn add lodash express bluebird
flow-typed install
Does an equivalent tool exist for TypeScript?
If using the legacy version of yarn (v1) - which is still very common - I have found no solution.
However, modern yarn (v2+) supports a plugin infrastructure and just such a plugin exists: the plugin-typescript.
This plugin offers a range of features, one being "Automatically adds @types/ packages into your dependencies when you add a package that doesn't include its own types".