【问题标题】:Typescript compiler doesnt seem to be honouring my skipLibCheck flag being set to trueTypescript 编译器似乎不尊重我的 skipLibCheck 标志设置为 true
【发布时间】:2021-06-29 21:57:12
【问题描述】:

我在我的项目中收到一堆我想要抑制的库 d.ts 文件的语法问题。我看到“skipLibCheck”选项可用,我在我的配置中设置为 true,但这没有区别:

ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\leaflet\index.d.ts
[tsl] ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\leaflet\index.d.ts(594,5)
      TS7028: Unused label.

ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\handlebars\index.d.ts
[tsl] ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\handlebars\index.d.ts(22,31)
      TS1005: ',' expected.

ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\handlebars\index.d.ts
[tsl] ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\handlebars\index.d.ts(24,32)
      TS1005: ',' expected.

ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\handlebars\index.d.ts
[tsl] ERROR in C:\Users\\***\Documents\GitHub\\***\node_modules\@types\handlebars\index.d.ts(99,40)
      TS1005: ',' expected.

我的 tsconfig:

{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true,
        "outDir": "./dist",
        "rootDir": "../",
        "noImplicitAny": false,
        "noImplicitThis": false,
        "noUnusedLocals": false,
        "noUnusedParameters": false,
        "pretty": true,
        "removeComments": false,
        "allowUnreachableCode": false,
        "declaration": false,
        "allowJs": true,
        "module": "commonJs",
        "typeRoots" : ["./typings/index.d.ts", "../../node_modules/@types"],
        "skipLibCheck": true
    },
    "include": [
        "./typings/index.d.ts",
        "./app/**/*.module.ts",
        "./app/**/*.run.ts",
        "./app/**/*.routes.ts",
        "./app/**/*.enum.ts",
        "./app/**/*.controller.ts",
        "./app/**/*.model.ts",
        "./app/**/*.directive.ts",
        "./app/**/*.component.ts",
        "./app/**/*.filter.ts",
        "./app/**/*.service.ts",
        "./app/interfaces/**/*.ts"
    ],
    "exclude": [
        "dist"
    ]
}

我使用的是最新版本的 webpack (3.11.0),skipLibCheck 标志应该在这里工作吗?

谢谢

【问题讨论】:

  • 你的 tsconfig.json 看起来怎么样?
  • @cyrix - 我刚刚将它添加到我的原始帖子中,谢谢
  • 您应该将node_modules 添加到exclude 列表中,通常include 中的./app/**/*.ts 应该足够了。如果您有任何规范文件,还可以选择将**/*.spec.ts 转换为exclude
  • 感谢@cyrix,我在node_modules 中添加了exclude 选项,但这并没有消除错误
  • 删除typeRoots 有效吗?

标签: typescript


【解决方案1】:

skipLibCheck 跳过类型不一致检查,但您似乎有一些语法错误。 TS1005: ',' expected. 显然不是类型错误。

【讨论】:

    猜你喜欢
    • 2019-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    • 2014-07-17
    相关资源
    最近更新 更多