typesyncは、package.jsonをチェックして、不足しているTypeScriptの型定義ファイルを追加してくれるツールです。typesyncの実行前と実行後の状態を確認します。
目次
実行前
$ cat package.json | awk '/devDependencies/,/}/'
"devDependencies": {
"axios": "^0.19.0",
"jest": "^24.8.0",
"moment": "^2.24.0",
"puppeteer": "^1.17.0",
"ts-loader": "^6.0.2",
"typescript": "^3.5.1",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2"
}
typesyncを実行
$ npx typesync
npx: installed 44 in 3.955s
» TypeSync v0.5.1
✔ 2 new typings added.
???? ts-test-typesync — package.json (2 new typings added)
├─ @types/webpack
└─ @types/puppeteer
✨ Go ahead and run npm install or yarn to install the packages that were added.
実行後
$ cat package.json | awk '/devDependencies/,/}/'
"devDependencies": {
"@types/puppeteer": "^1.12.4",
"@types/webpack": "^4.4.32",
"axios": "^0.19.0",
"jest": "^24.8.0",
"moment": "^2.24.0",
"puppeteer": "^1.17.0",
"ts-loader": "^6.0.2",
"typescript": "^3.5.1",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2"
}
@types/puppeteer
と @types/webpack
が追記されています。
axios
などは、axiosのパッケージ自体に型定義ファイルが含まれているので、package.jsonへ追記はありません。
$ cat node_modules/axios/package.json | grep typings
"typings": "./index.d.ts",
$
$ ls node_modules/axios | grep index.d.ts
index.d.ts