π¦ Scan and install missing Typescript type definitions for dependencies in package.json
.
Table of Contents
- βοΈ Highly customazible and easy to use.
- βοΈ Detects whether a library has built-in typings or provided by DefinitelyTyped
- βοΈ Supports multiple
package.json
files and monorepos. - βοΈ Matches version of
@types
with its corresponding package. See here for details. - βοΈ Installs them with automatically detected package manager or just updates
package.json
file.
Install package either locally in your project or globally:
# locally
npm install typle --save-dev
# globally
npm install typle -g
Alternatively, use npx
directly:
npx typle
Run typle in the root of your project with package.json
inside it.
This will scan package.json
for missing typescript declarations and install them:
npx typle
typle [paths/to/package.json] [--options]
Paths can be either file paths or glob patterns, e.g. typle packages/*
when working with a monorepo.
typle install <package-names> [--options]
Simply install packages with their corresponding type declarations.
All flags will be passed to a given package manager's options.
Available under alias i
.
$ typle -h
typle
Usage
$ typle [flags...] [patterns...]
Scan and install missing Typescript type definitions for dependencies in 'package.json'.
Commands
install Install packages with their corresponding type declarations. (alias: 'i')
Options
-h, --help Show help.
-v, --version Get version.
--silent Run install silently.
--install Whether to install packages automatically or just update package.json.
--pkg-manager [manager] Which package manager to use.
--ignore-packages [packages...] List of packages to ignore.
--ignore-deps [deps...] List of certain dependency fields to ignore e.g. 'dev'.
--config [path] Path to the config file.
--dry-run It won't cause any changes to package.json.
Examples
$ typle --ignore-packages nodemon eslint
$ typle packages/*
Options that aren't prefixed with double dash (--
) are strictly for CLI.
Option | Description | Default |
---|---|---|
--silent |
Run install silently. | true |
--install |
Whether to install packages automatically or just update package.json . |
true |
--pkg-manager |
Which package manager to use. Allowed: npm, yarn, pnpm or bun. | Automatically detected. |
--ignore-packages |
List of packages to ignore. | - |
--ignore-deps |
List of certain dependency fields to ignore, e.g. to ignore devDependencies use --ignore-deps devDependencies or --ignore-deps dev for shorthand. |
- |
--config |
Path to the config file. | - |
--dry-run |
If specified, it won't make any changes in package.json or install any packages. |
false |
patterns |
Paths or globs where package.json files will be scanned. |
- |
additionalArgs |
Additional arguments for package install. | - |
-v, --version |
Show version. | - |
-h, --help |
Show help. | - |
Alternatively, you can use a configuration file instead with the same options in: .typlerc.js
file (or any other config file supported) or typleConfig
field in your package.json
. See lilconfig for more details.
You might also find use of defineConfig
wrapper function that will help you with defining configuration:
// .typlerc.js
import { defineConfig } from 'typle';
export default defineConfig({
silent: false,
patterns: 'packages/*',
ignorePackages: ['nodemon', 'eslint'],
/** etc... */
});
package.json
.typlerc.js
.typlerc.cjs
.typlerc.json
typle.config.js
typle.config.cjs
.config/typlerc
.config/typlerc.json
.config/typlerc.js
.config/typlerc.cjs
.typlerc.ts
.typlerc.mts
.typlerc.cts
typle.config.ts
typle.config.mts
typle.config.cts
.config/typlerc.ts
.config/typlerc.mts
.config/typlerc.cts
If you wish to store config in some other file path use --config
option.
You can use typle in a monorepo too!
ββββ typle (root folder)
ββββ packages
β ββββ typle
β ββββ typle-core
β ββββ typle-util
ββββ .typlerc.json
ββββ package.json
In this example monorepo, in order to scan every folder in packages
directory we can use the following config:
// .typlerc.json
{
"patterns": "packages/*"
}
Then run typle
in the root directory.
Installing typings manually is just annoying and sometimes quite vague.
Typle was heavly inspired by typesync, but with many improvements and new features.
MIT π