【发布时间】:2017-03-09 19:42:02
【问题描述】:
整个 main.ts:
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
// depending on the env mode, enable prod mode or add debugging modules
if (process.env.ENV === 'build') {
enableProdMode();
}
export function main() {
return platformBrowserDynamic().bootstrapModule(AppModule);
}
if (document.readyState === 'complete') {
main();
} else {
document.addEventListener('DOMContentLoaded', main);
}
一些错误(不是全部):
[default] /xxx/src/main.ts:11:96
Index signature of object type implicitly has an 'any' type.
...
[default] /xxx/src/main.ts:11:853
Parameter 'store' implicitly has an 'any' type.
报告的位置(例如 11:96、11:853)是无用的 - 那里什么都没有。我应该如何处理这些严重报告的错误?我怎样才能找到这些错误的真实位置?如何修复它,使其正确报告?
我正在使用这个种子 - https://github.com/preboot/angular2-webpack/(我认为主文件未修改)。
我在tsconfig.json添加了以下内容:
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
请注意,我想要所有这些支票。
这也很奇怪,它报告的标识符不在我的代码中。例如:
Parameter 'dependencies' implicitly has an 'any' type.
由于这个和大量错误,我开始怀疑它在库中报告错误(这很奇怪,因为我有 skipLibCheck)或在连接的结果文件中(这也很奇怪,因为一切都在编译到 es5)。但是我没有使用 TypeScript 编译器或 Webpack 的经验,所以我真的说不出来。
Edit1:在 TypeScript repo 询问后,很明显编译器工作正常。罪魁祸首可能是 TS 加载器或 webpack 本身。
Edit2:已经一个多月了,webpack 伙计们doesn't seem to be doing anything 关于它:(。
【问题讨论】:
标签: angular typescript webpack