noImplicitAny: false
并不能真正解决问题,只是忽略了它。
template
将隐式键入为
any
因为找不到类型。您不会得到错误,但也不会得到类型安全性。
真正的问题是你指定了
"types": [ "node" ],
这意味着只有节点模块的类型来自
typeRoots
. 见
docs
.
最简单的解决方案是移除
types
元素从
tsconfig.json
. 此tsconfig不提供任何错误:
{
"compilerOptions": {
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2017" ],
"module": "CommonJS",
"noImplicitReturns": true,
"outDir": "lib",
"removeComments": true,
"sourceMap": true,
"strict": true,
"target": "es2017",
"typeRoots": [ "./typings", "./node_modules/@types" ]
},
"compileOnSave": true,
"include": [ "./src/**/*" ]
}