【问题标题】:WebStorm doesn't use tsconfig compiler options (Angular app)WebStorm 不使用 tsconfig 编译器选项(Angular 应用程序)
【发布时间】:2018-10-27 21:17:07
【问题描述】:

我有一个由angular-cli 生成的默认项目结构,其中有一个根tsconfig.jsonsrc/tsconfig.app.jsonsrc/tsconfig.spec.json。虽然我在根配置中打开了noImplicitAnystrict 选项,但当我没有指定函数参数类型或将number 类型变量分配给null 时,我的编辑器中没有出现错误曲线。

如何配置 WebStorm 以使用我的根 tsconfig.json 为我提供提示?

这是我的根tsconfig.json

{
"compileOnSave": false,
"compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "target": "esnext",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom",
      "esnext"
    ],
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,

    "strict":                     true,
    "strictNullChecks":           true,
    "noUnusedLocals":             true,
    "noUnusedParameters":         true,
    "noImplicitAny":              true,
    "noImplicitThis":             true,
    "noImplicitReturns":          true,
    "noFallthroughCasesInSwitch": true
}
}

我的 TypeScript WebStorm 设置:

即使我在tsconfig.json 中指定"files""include" 选项以指向我的*.ts 文件,也不会出现错误,尽管在我以前的(非角度)应用程序中一切正常。如果我在项目根目录中运行 tsc,我会收到一堆预期的错误消息,但仍然没有提供编辑器提示。

【问题讨论】:

    标签: angular typescript webstorm tsconfig


    【解决方案1】:

    我已经通过选择退出 "Angular language service" 来解决问题,因为我在 TypeScript 控制台中不断收到错误消息: Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined

    This is a bug

    【讨论】:

    • 2018.3 版本显示“已修复”。
    猜你喜欢
    • 2019-10-07
    • 2020-08-20
    • 1970-01-01
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-17
    相关资源
    最近更新 更多