Try   HackMD

【Typescript】程式碼檢查

程式碼檢查工具

  1. TSC
  2. ESLint
  3. TSLint

tsc 與 tslint 之間也有一些重複的檢測,但是大部分都是因為早期的 tsc 還沒能做到檢測此類別錯誤。

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

優缺點比較

  • TSLint 的優點:

    1. 專為 TypeScript 服務,bug 比 ESLint 少
    2. 不受限於 ESLint 使用的語法樹 ESTree
    3. 能直接透過 tsconfig.json 中的配置編譯整個專案,使得在一個檔案中的型別定義能夠聯動到其他檔案中的程式碼檢查
  • ESLint 的優點:

    1. 基礎規則比 TSLint 多很多
    2. 社群繁榮,外掛眾多
  • 是否使用TSLint的參考

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    一些例子

安裝勘誤:
typescript-eslint-parser -> @typescript-eslint/parser