2017-08-01 51 views
0

我已經使用angular 4和typescript 2.4.2設置了visual studio Web應用程序。 但我仍然從業力和茉莉花文件中獲得與打字稿有關的一些錯誤。在Visual Studio Web應用程序中的.spec文件中輸入腳本錯誤

我試着將es5改成es6,但仍然出現錯誤。我已經閱讀了很多解決方案,但都沒有工作。

截圖錯誤

enter image description here

下面的是的package.json

{ 
    "name": "angularapp", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/animations": "^4.0.0", 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/router": "^4.0.0", 
    "@types/bootstrap": "^3.3.35", 
    "@types/jquery": "^3.2.10", 
    "bootstrap": "^3.3.7", 
    "core-js": "^2.4.1", 
    "rxjs": "^5.4.1", 
    "systemjs": "^0.20.16", 
    "zone.js": "^0.8.14" 
    }, 
    "devDependencies": { 
    "@angular/cli": "1.2.3", 
    "@angular/compiler-cli": "^4.0.0", 
    "@angular/language-service": "^4.0.0", 
    "@types/jasmine": "~2.5.53", 
    "@types/jasminewd2": "~2.0.2", 
    "@types/node": "^6.0.85", 
    "codelyzer": "~3.0.1", 
    "jasmine-core": "~2.6.2", 
    "jasmine-spec-reporter": "~4.1.0", 
    "karma": "~1.7.0", 
    "karma-chrome-launcher": "~2.1.1", 
    "karma-cli": "~1.0.1", 
    "karma-coverage-istanbul-reporter": "^1.2.1", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "protractor": "~5.1.2", 
    "ts-node": "~3.0.4", 
    "tslint": "~5.3.2", 
    "typescript": "~2.4.2" 
    } 
} 

tsconfig.json

{ 
    "compilerOptions": { 
    "target": "es6", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es6", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "types": [ 
     "jquery", 
     "bootstrap", 
     "node" 
    ], 
    "typeRoots": [ 
      // add path to @types 
      "node_modules/@types" 
     ] 
    } 
} 

回答

0

所以這是我做過什麼

  1. NPM升級
  2. NPM安裝--save-dev的 「@類型/茉莉花」,從「
  3. 然後在app.component.spec.ts 進口{}茉莉花「;

乾淨,並建立它工作正常。

謝謝

相關問題