# 【Typescript】程式碼檢查 ## 程式碼檢查工具 1. TSC 2. ESLint 3. [TSLint](https://github.com/eslint/typescript-eslint-parser) * 先來看看[例子](https://willh.gitbook.io/typescript-tutorial/engineering/lint#wei-shen-me-xu-yao-cheng-shi-ma-jian-cha) :::info tsc 與 tslint 之間也有一些重複的檢測,但是大部分都是因為早期的 tsc 還沒能做到檢測此類別錯誤。 ::: ![image](https://hackmd.io/_uploads/HyV4KZXTp.png) ## 優缺點比較 * TSLint 的優點: 1. 專為 TypeScript 服務,bug 比 ESLint 少 2. 不受限於 ESLint 使用的語法樹 ESTree 3. 能直接透過 tsconfig.json 中的配置編譯整個專案,使得在一個檔案中的型別定義能夠聯動到其他檔案中的程式碼檢查 * ESLint 的優點: 1. 基礎規則比 TSLint 多很多 2. 社群繁榮,外掛眾多 * 是否使用TSLint的參考 ![image](https://hackmd.io/_uploads/SJztM6I6p.png) 一些[例子](![image](https://hackmd.io/_uploads/H14kH6Iaa.png)) 安裝勘誤: `typescript-eslint-parser` -> `@typescript-eslint/parser`