我正在使用Typescript 2,除非我在我的规范文件的顶部放置/// <reference path="..." />
,否则会收到错误Cannot find name 'describe'
这是我的spec文件:
/// <reference path="../../../../node_modules/@types/jasmine/index.d.ts" />
import { DashboardSlotComponent } from './dashboard-slot.component';
import { DashboardSlot } from './dashboard-slot.model';
describe('Given a dashboard slot component', () => {
let sut: DashboardSlotComponent;
beforeEach(() => {
sut = new DashboardSlotComponent();
});
...
的package.json
"typescript": "2.0.2",
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmitHelpers": true,
"strictNullChecks": false,
"baseUrl": "./src",
"paths": [
],
"lib": [
"dom",
"es6"
],
"types": [
"angular",
"hammerjs",
"jasmine",
"node",
"selenium-webdriver",
"source-map",
"uglify-js",
"webpack"
]
},
"exclude": [
"dist",
"node_modules"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
我正在使用带有Typescript 2扩展的Visual Studio 2015。
答案 0 :(得分:1)
使用Typescript 2,尝试:
/// <reference types="jasmine" />
并确保你npm install @ types / jasmine