LoginSignup
2
2

More than 3 years have passed since last update.

爆速でTypeScriptの環境構築できるgts使ってみた

Last updated at Posted at 2021-03-01

gts とは

Google の TypeScript コーディングスタイルガイドです.
TypeScript や Eslint, Prettierなど の環境構築や設定などをコマンド一発でやってくれます.

導入


> npx gtx init
> yarn install (or npm install)

だけです, めっちゃ楽ですね.

npm スクリプト

導入した時点で作成されたスクリプトは以下です.


 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "lint": "gts lint",
    "clean": "gts clean",
    "compile": "tsc",
    "fix": "gts fix",
    "prepare": "npm run compile",
    "pretest": "npm run compile",
    "posttest": "npm run lint"
  },

コンパイルの環境も構築してくれるみたいですね.

実行

> yarn lint

コードフォーマットの確認をしてくれます.
問題があればいつものようにwarningが出ます.


> yarn fix

コードフォーマットの上書き修正をしてくれます.


> yarn compile

src 以下のファイルを build 以下にコンパイルしてくれます.


> yarn clean
> yarn pretest
> yarn postest
> yarn prepare

build 以下の削除, テストなどをしてくれます.

使ってみた感想

Lintツール独特の面倒な設定などを一発でやってくれるのはとてもありがたいですね.小さいプロジェクトなどで活用できればいいなと思います.めっちゃ楽!わかりやすい!ですね.

参考

gts - npm

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2