【发布时间】: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