VS Code was designed to be the perfect TypeScript editor.
    如果你用其他编辑器,我们可以全局安装TypeScript command-line tool

    1. npm install -g typescript
    2. # 或者
    3. yarn global add typescript

    进入项目文件夹,执行命令

    1. tsc --init

    则会创建tsconfig.json文件

    1. {
    2. "compilerOptions": {
    3. "target": "ES2020",
    4. "module": "es2020",
    5. "allowJs": true,
    6. "checkJs": true,
    7. "typeRoots": [
    8. "@types",
    9. "node_modules/@types"
    10. ],
    11. "esModuleInterop": true,
    12. }
    13. }

    执行下列命令进行类型检查,且不产生输出文件

    1. tsc --noEmit