语义错误为Angular 2编写NgMatchers打字脚本
Semantic errors typescript NgMatchers for Angular 2
我正试图用Gulp和jasmine(在看到这个例子之后)建立一个Angular 2项目,但不知何故,在编译我的typescript时,我一直收到这些语义错误:
matchers.d.ts(4,37): error TS2503: Cannot find namespace 'jasmine'.
process/typescript/app-component.spec.ts(8,22): error TS2339: Property 'toEqual' does not exist on type 'NgMatchers'.
对于以下测试用例:
import {it, describe, expect, beforeEach, inject} from 'angular2/testing';
import {AppComponent} from "./app.component";
describe('App component test', () => {
let component: AppComponent;
it('Value of testvar should be test', () => {
expect(true).toEqual(true);
});
});
我不知道哪里出了问题,尤其是因为我正在加载茉莉花打字机。。。typeings.json
{
"ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#5c182b9af717f73146399c2485f70f1e2ac0ff2b"
}
}
gullfile.js
var gulp = require('gulp'),
webserver = require('gulp-webserver'),
typescript = require('gulp-typescript'),
sourcemaps = require('gulp-sourcemaps'),
tscConfig = require('./tsconfig.json');
gulp.task('typescript', function () {
return gulp
.src(tsSrc + '**/*.ts')
.pipe(sourcemaps.init())
.pipe(typescript(tscConfig.compilerOptions))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(appSrc + 'js/'));
});
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true
},
"exclude": [
"node_modules"
]
}
有人知道出了什么问题吗?据我所知,我正在装载所有必要的包裹。
package.json
"dependencies": {
"angular2": "2.0.0-beta.15",
"systemjs": "^0.19.24",
"es6-promise": "^3.0.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.6.11"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "^2.13.0",
"gulp-webserver": "^0.9.1",
"http-server": "",
"jasmine-core": "^2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-coverage": "^0.5.5",
"karma-jasmine": "^0.3.8",
"remap-istanbul": "^0.6.3",
"typescript": "^1.8.10",
"typings": "^0.6.8"
}
我怀疑编译器需要像这样的声明文件
/// <reference path="../node_modules/angular2/typings/browser.d.ts" />
/// <reference path="../typings/main/ambient/jasmine/index.d.ts" />
import {it, describe, expect, beforeEach, inject} from 'angular2/testing';
import {AppComponent} from "./app.component";
describe('App component test', () => {
let component: AppComponent;
it('Value of testvar should be test', () => {
expect(true).toEqual(true);
});
});
相关文章:
- 当包含另一个asp文件时,是否也包含所有引用的样式和脚本页面
- 借助asp.net验证或java脚本对多个文本进行验证
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- Java脚本时间添加
- 不显示带有本地json文件数据的谷歌地图脚本
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 从远程脚本获取用户IP
- 如何根据时间运行不同的脚本
- 如何将字符串值从php页面发送到java脚本页面
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- 当脚本由system.js加载时,如何要求('electron')
- HTML标记在脚本标记中工作
- 是否可以控制获取哪些Google地图脚本(JavaScript API)
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- 显示时间的脚本
- ng应用程序使脚本无限运行
- 如何在运行时在angular 2中加载外部js脚本
- Google Adsense多次加载脚本
- 语义错误为Angular 2编写NgMatchers打字脚本