我正在为我的应用程序使用一些依赖项,比如模块fuse-box
tsconfig:
{
"compilerOptions": {
"noImplicitAny": true
},
"exclude": [
"**/node_modules/*",
]
}我的代码库中有一个文件:
import { FuseBox } from 'fuse-box'
FuseBox.init({
homeDir: '.',
outFile: './built/out.js'
}).bundle('>app.ts')TSC编译器给出了错误:
../node_modules/fuse-box/dist/typings/c
ore/WorkflowContext.d.ts(137,9): error TS7020: Call signature, which lacks retu
rn-type annotation, implicitly has an 'any' return type.这是因为我的noImplicitAny": true设置。我只是在想,为什么它会分析出我的代码库中的东西,然后打印错误。这样的错误对开发过程和编译安全吗?
发布于 2017-03-22 05:25:50
编译器需要遍历模块类型,以便为您进行适当的类型检查。
如果您想关闭它,可以在您的tsconfig.json中这样做:
{
"compilerOptions": {
"skipLibCheck": true
}
}这需要TypeScript 2.0
更新:随着TypeScript使用量的增加和用例的扩展,我们开始看到即使skipLibCheck设置为true也会出现问题。
其中一个问题是,如果包中包含node_modules文件,它不会跳过签入.ts。
问题标记为working as intended。
此外,如果包使用的TypeScript版本与您正在使用的版本不同,并且它们之间会有中断的更改,那么您就会遇到编译错误。
https://stackoverflow.com/questions/42934675
复制相似问题