- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
现在我已经更新了 my application到 Angular2 v2.0.0-rc.1,当我的应用程序被捆绑在 webpack 中时,我再次看到 TypeScript 编译错误/警告消息.这些消息出现在我从 TypeScript 源文件中引用的任何 @angular
包中,例如:
ERROR in ./src/app/app.ts
(1,34): error TS2307: Cannot find module '@angular/core'.
ERROR in ./src/app/app.ts
(3,76): error TS2307: Cannot find module '@angular/common'.
ERROR in ./src/app/app.ts
(4,30): error TS2307: Cannot find module '@angular/http'.
在 Angular2 的早期 beta 版本中,我通过在 的顶部包含类似这样的内容来解决类似
文件。Promise
和 Map
类的消息问题app.ts
///<reference path="node_modules/angular2/typings/browser.d.ts"/>
是否有 @angular
Angular2 包的 d.ts
文件可供我引用以解决问题?到目前为止,typings
系统似乎没有任何可用的东西:
MFO-Mac:angular2-oauth2 mfo$ typings search '@angular'
No results found for search
现在我将我的 TypeScript tsconfig.json
文件配置为以 ES6 为目标。但是,如果我将其更改为以 ES5 为目标,我不会收到这些 @angular
错误,而是会收到常见 ES6 类的错误,例如 Promise
、Set
和 map
。这是我为 ES6 配置的文件:
{
"version": "1.6.2",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"module": "commonjs",
"removeComments": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"bower_components",
"bootstrap"
],
"files": [],
"definitions": [
]
}
我怀疑 node_modules/@angular
中有我可以在 tsconfig.json
文件的 definitions
部分中列出的文件,但我目前对 TypeScript typedef 文件的工作原理知之甚少。
如果有其他方法可以解决这个问题,我当然也会接受。
最佳答案
如果您告诉 TypeScript 编译器您使用的是 Node/NPM 样式模块,TypeScript 编译器似乎足够聪明,可以自行判断文件定义文件。
通过将 "moduleResolution": "node",
添加到我的 tsconfig.json
文件中,问题消息消失了,应用程序继续按预期工作。
这是我的新文件(新添加的是第 4 行):
{
"version": "1.6.2",
"compilerOptions": {
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"module": "commonjs",
"removeComments": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"bower_components",
"bootstrap"
],
"files": [],
"definitions": []
}
关于javascript - Angular 2 中缺少 @Angular 包的 TypeScript 类型定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37059364/
我正在尝试在 map 上绘制一些疾病事件数据的位置。 我用它来导入数据: ByTown% addProviderTiles("CartoDB.Positron")%>% addPolygons
我有一个文件调用 find.js,我使用 node find.js 运行,我的节点是版本 10 我不知道为什么我无法使用 async await。 const axios = require("axi
我有一个项目作为引用添加到 System.Web。 但是,它似乎无法获取 HttpContext。这样做: Imports System.Web _ApplicationBase = HttpCont
在互联网上找到这段代码,出于某种原因它缺少 while 循环逻辑“while(i....)”,虽然我找到了 PigLatin* 问题的其他可行解决方案,但我真的很想了解这个正在工作。 *PigLati
我工作了一整天来运行 Xampp 并在其上安装 TYPO3。现在我登录到后端,但没有显示许多管理模块,例如模板、访问等。 - 一定是我做错了什么,但我不知道。 these are the module
你好 我有编译这个问题 \begin{equation} J = \sum_{j=1}^{C} \end{equation} 我不断收到错误 missing $ inserted 这很奇怪,因
我正在尝试使用 SQLite CLI,但无法获得 generate_series功能来工作。我可以按照文档中的建议使用递归 CTE 对其进行模拟,但我似乎无法获得该链接中的任何示例。这是我的 sess
我目前正在开发我想要的软件,而软件正在安装,它可以在后台为软件创建 native 图像。 我正在考虑使用 NGEN 并将进程优先级设置为低,因为我不希望它消耗 100% CPU。但是我发现我的计算机上
我想使用 Xcodes Instruments 进行 UI 自动化测试。但似乎缺少“自动化”。我怎样才能添加这个? 最佳答案 如果您想使用自动化仪器,请使用 Xcode 7.3。 Apple 在 Xc
我目前在 JS 开发中迈出了一小步,并编写了以下链接添加器: const button = document.getElementById('button') const listdiv = docu
此代码有什么问题: NSError *error = nil; [SFHFKeychainUtils deleteItemForUsername:@"IAPNoob01" andServiceName
出于某种原因,在安装和配置(我认为)一切之后,com.adobe.utils.AGALMiniAssembler 不见了,其他一切正常。 我认为我已尽一切努力让孵化器正常工作,但显然我错过了一步。 如
我有一个名为 new 的方法。调用 new 时,我传递了一个参数,但是当我运行应用程序时,出现没有参数或参数为空的错误。 StepReader.pm package StepReader; use s
安装 gtk 1.2(包名 gtk1)和 macports chokes 在最终的 make 中,在 libintl.h 的第 440 行。 extern locale_t libintl_newlo
我用按钮创建表格。 这是javascript代码: function layersListTable(layers) { var content =''; $.each($(layer
我在使用此 javascript 时遇到此错误,任何人都可以帮我弄清楚我做错了什么吗? $(this).prepend('Check availability »'); 它给我错误 mis
我有一个独立的工具链 NDK13b、api19、llvm 3.8 编译器、arm 32 位、带有 libcpp(llvm C++ 库) 我想避免依赖 libgcc,所以我构建了 compiler-rt
我按照一些教程使用 phonegap 的条形码扫描器插件。但是当我从现有源创建一个新的 android 项目来创建条码库时 (step 6 in this page)我收到错误:“AndroidMan
我现在尝试在 Eclipse 中打开我的布局 xml 文件。我只得到错误 No XML content. Please add a root view or layout to your docume
我的 android-sdk-windows\tools 目录中缺少层次结构查看器工具。 工具链接: http://developer.android.com/guide/developing/too
我是一名优秀的程序员,十分优秀!