- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我为目标 ES5 编译 @angular (2.0.0) 时,我收到一堆错误:
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\common\src\directives\ng_class.d.ts 46 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\common\src\pipes\async_pipe.d.ts 39 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\compile_metadata.d.ts 347 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\compile_metadata.d.ts 348 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\directive_normalizer.d.ts 19 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\directive_normalizer.d.ts 21 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\offline_compiler.d.ts 15 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\offline_compiler.d.ts 16 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\offline_compiler.d.ts 31 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\output\output_ast.d.ts 424 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\resource_loader.d.ts 13 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\runtime_compiler.d.ts 40 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\runtime_compiler.d.ts 42 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\template_parser\template_parser.d.ts 45 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\util.d.ts 35 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\util.d.ts 36 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\view_compiler\compile_element.d.ts 33 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\view_compiler\compile_query.d.ts 24 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\view_compiler\compile_view.d.ts 29 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\view_compiler\compile_view.d.ts 52 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\compiler\src\view_compiler\compile_view.d.ts 54 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\application_init.d.ts 16 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\application_ref.d.ts 106 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\application_ref.d.ts 122 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\application_ref.d.ts 148 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\application_ref.d.ts 150 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\change_detection\differs\default_keyvalue_differ.d.ts 24 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\change_detection\differs\default_keyvalue_differ.d.ts 28 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\di\reflective_provider.d.ts 88 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\di\reflective_provider.d.ts 88 Active
Error TS2304 Cannot find name 'MapConstructor'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 2 Active
Error TS2304 Cannot find name 'SetConstructor'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 3 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 5 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 5 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 8 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 9 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 12 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 13 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 15 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 16 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 101 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 102 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\collection.d.ts 103 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\lang.d.ts 12 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\lang.d.ts 13 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\facade\lang.d.ts 51 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\linker\compiler.d.ts 53 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\linker\compiler.d.ts 61 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\linker\ng_module_factory_loader.d.ts 14 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\core\src\linker\system_js_ng_module_factory_loader.d.ts 28 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser-dynamic\src\resource_loader\resource_loader_impl.d.ts 10 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\browser\browser_adapter.d.ts 79 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\dom\dom_adapter.d.ts 97 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\dom\dom_renderer.d.ts 18 Active
Error TS2304 Cannot find name 'MapConstructor'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 2 Active
Error TS2304 Cannot find name 'SetConstructor'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 3 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 5 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 5 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 8 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 9 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 12 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 13 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 15 Active
Error TS2304 Cannot find name 'Map'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 16 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 101 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 102 Active
Error TS2304 Cannot find name 'Set'. TypeScript Virtual Projects C:\xxx\node_modules\@angular\platform-browser\src\facade\collection.d.ts 103 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\rxjs\Observable.d.ts 10 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\rxjs\Observable.d.ts 66 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects C:\xxx\node_modules\rxjs\Observable.d.ts 66 Active
我读到 Angular 2 应该与 IE9 一起工作,所以它应该转换为 ecmascript 5,此外这是官方教程中的内容。请问如何消除这些错误?
最佳答案
我终于让它工作了:
我的确切设置是:
打字.json
{
"globalDependencies": {
"core-js": "registry:dt/core-js",
"node": "registry:dt/node",
"jquery": "registry:dt/jquery"
}
}
gulpfile.js
/// <binding />
var gulp = require('gulp');
gulp.task('default', function () {
// place code for your default task here
});
gulp.task('restore', function () {
gulp.src([
'node_modules/@angular/**/*.js',
'node_modules/angular2-in-memory-web-api/*.js',
'node_modules/rxjs/**/*.js',
'node_modules/systemjs/dist/*.js',
'node_modules/zone.js/dist/*.js',
'node_modules/core-js/client/*.js',
'node_modules/reflect-metadata/reflect.js',
'node_modules/jquery/dist/*.js',
'node_modules/es6-promise/*.js',
'node_modules/es6-shim/*.js',
'node_modules/bootstrap/dist/**/*.*'
]).pipe(gulp.dest('./wwwroot/libs'));
});
我从 Task Runner Explorer 手动运行它(每次运行都需要很长时间)。
package.json
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install && gulp restore",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"dependencies": {
"rxjs": "*",
"zone.js": "*",
"reflect-metadata": "^0.1.3",
"systemjs": "0.19.27",
"es6-promise": "^3.1.2",
"es6-shim": "^0.35.0",
"jquery": "^2.2.4",
"bootstrap": "^3.3.6",
"@angular/core": "2.0.0",
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"angular2-in-memory-web-api": "0.0.20"
},
"devDependencies": {
"gulp": "^3.9.1",
"concurrently": "^2.0.0",
"typings": "^1.0.4"
},
"peerDependencies": {
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"diagnostics": true
},
"exclude": [
"node_modules"
]
}
许多教程都介绍了 es6-shim,但它目前使用的是 core-js,如果不小心,最终会出现重复的声明。
关于javascript - @Angular (Angular 2) 无法使用 es5 进行编译 - Set、Map 等缺失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39660063/
我编写了一个 Android 应用程序,它使用 Azure 来执行用户通过 Google、Twitter 和 Facebook 的登录;它使用 Microsoft.WindowsAzure.Mobil
我想将 AdomdClient 引用添加到 C# 项目,但它不在引用列表中。客户端列在程序集文件夹 C:\Windows\Assembly 中。 计算机上安装了 SQL Server 2012。 最佳
我正在学习“绘图应用程序”的教程。当我在 Firefox 上启动我的应用程序时,Firebug 告诉我“在语句之前缺少 ;” 我在第 9 行调用函数的位置。我只是不明白应该将这些“;”放在哪里. va
我想将 AdomdClient 引用添加到 C# 项目,但它不在引用列表中。客户端列在程序集文件夹 C:\Windows\Assembly 中。 计算机上安装了 SQL Server 2012。 最佳
我在 Firebug 中不断收到关于 onClick 事件的错误。 我已经尝试了 "和 ' 的各种不同组合,但无济于事。在添加 onClick 事件之前,这工作正常。 有人能发现我可能做错了什么吗?
Visual Studio 2015 告诉我找不到 WSASetSocketSecurity。 该 dll 存在并且还包括似乎没问题。 我的包括: windows.h stdio.h Wincrypt
我需要访问 eloquent 的 whereHasNot方法(此处添加: https://github.com/laravel/framework/commit/8f0cb08d8ebd157cbfe
跟随宠物物体检测的 TF 教程:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/run
构建路径 > 添加库 > JUnit 无法添加 JUnit3 或 JUnit4 组件。 我在.log 中看到这样的消息 !MESSAGE No property tester contributes
我正在运行此脚本来查看网络上的摄像机: gst-launch udpsrc port=1234 ! "application/x-rtp, payload=127" ! rtph264depay !
我正在使用http://java.sun.com/jsp/jstl/fmt用于从 Spring 配置中设置的 Message Resource Bundle 输出消息的标签库。消息解析也可以放在 Co
我正在将 Ninject 与 MVC4 连接起来,并让它工作到尝试实际解决依赖关系的程度。但是,我收到以下异常: Method not found: 'System.Web.Http.Services
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 9 年前。 Improve
我在启动 ASP.NET MVC5 应用程序时遇到问题。到目前为止一切正常。启动应用程序时出现以下错误: Could not load file or assembly 'Microsoft.Appl
我已经使用以下方法创建了一个环境: conda create --prefix C:\Users\Dell\Dropbox\DjangoProjects\webenv python=3.6 执行后:c
我们有一个遗留的 Web 窗体应用程序,我们最近将其从网站项目转换为 Web 应用程序项目。 Web 窗体项目是解决方案的“启动”项目。 有一个 MVC 项目是对 Web 窗体项目的引用。 在 MVC
使用某种字体,我使用Java的FontLayout来确定它的上升、下降和行距。 (参见 Java 的 FontLayout 教程 here) 在我的具体案例中,我使用的是 Arial Unicode
我正在尝试在 linux 下编译 qt ffmpeg 包装器简单编码/解码示例 QTFFmpegWrapper source # Set list of required FFmpeg librari
我正在使用来自开发人员 android 页面的 SlidingTabLayout.java。在我使用 slidingTabLayout.setDistributeEvenly(true); 使 sli
我正在尝试使用 v360 filter 将 180° 鱼眼视频转换为普通/常规视频的 FFmpeg . 这是我尝试过的命令:ffmpeg -i in.mp4 -vf "v360=input=fishe
我是一名优秀的程序员,十分优秀!