【发布时间】:2015-11-30 22:24:21
【问题描述】:
我正在 Atom 中使用 atom-typescript 开发一个使用 Angular2 的小型测试应用程序。我对 angular2.d.ts 的初始设置使用了 alpha.28,而 router.d.ts 使用了 alpha.31。我已将 index.html 更新为 alpha.46
<script src="https://code.angularjs.org/2.0.0-alpha.46/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.46/router.dev.js"></script>
现在,当我导入 ROUTE_PROVIDERS 之类的内容时,atom-typescript 会给我一个未找到的错误。我也得到 router.d.ts 找不到名称“不透明令牌”。
我想我需要匹配 alpha.46 的 d.ts 文件。经过几个小时的搜索和尝试,我无法做到这一点。我尝试 npm install angular2 将命令行光标放在 typings/angular2 上,我得到一个错误日志,其中包含 12,031 行,但没有新的 d.ts 文件。在很多方面,我还尝试了 Chrome 的空缓存和硬重载。
如何获得与 angular2 版本匹配的 d.ts 文件?是否可以自动更新,使其始终与 index.html 中的 angular2 版本匹配?
如果有帮助,这是我的 tsconfig.json 文件
{
"compilerOptions": {
"charset": " UTF-8",
"declaration": false,
"diagnostics": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"listFiles": true,
"module": "commonjs",
"noImplicitAny": false,
"noLib": false,
"outDir": "dist/js/cjs",
"rootDir": "src",
"removeComments": true,
"sourceMap": true,
"target": "es5",
"version": true
},
"filesGlob": [
"./**/*.ts",
"!node_modules/**"
],
"exclude": [
"node_modules"
],
"files": [
"./app.ts",
"./src/components/navigation/home.ts",
"./src/components/navigation/postApartment4Rent.ts",
"./typings/angular2/angular2.d.ts",
"./typings/angular2/router.d.ts",
"./typings/es6-promise/es6-promise.d.ts",
"./typings/rx/rx-lite.d.ts",
"./typings/rx/rx.d.ts",
"./typings/tsd.d.ts"
],
"atom": {
"rewriteTsconfig": true
},
"buildOnSave": true,
"compileOnSave ": true
}
【问题讨论】:
-
查看issue
-
埃里克,谢谢。我在您发送给我的问题页面上发布了我收到的错误的描述。我可能搞砸了,但我认为 angular2 团队需要做一些工作才能让 typescript 在 IDE 中为最近的 alpha 版本工作。
-
我发布的问题是我的。我修复了它们,npm 将 alpha.47 安装到我的项目代码中。 atom-typescript 仍然没有找到像 ROUTE_PROVIDERS 这样的新实体。我可能要等到更多 angular2 文档出来。
标签: typescript angular atom-editor