编译

时间:2017-10-11 05:37:25

标签: angularjs json typescript intellij-idea package.json

在IntelliJ-Idea 2017.1.1 IDE中获取TypeScript错误

我尝试过启用JavaScript,NodeJS和TypeScript编译器。

我已经尝试了一切,但没有得到修复,我可能会遗漏某处。

  

错误:初始化错误(打字稿)。无法读取属性' createHash of undefined

任何人都可以帮我解决吗?

enter image description here

enter image description here

的package.json

{
  "name": "TempPractice",
  "version": "0.0.1",
  "description": "First Angular App",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git@github.com:angularjs-de/angularjs-typescript-seed.git"
  },
  "main": "app/app.ts",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install",
    "update-deps": "npm update",
    "postupdate-deps": "bower update",
    "prestart": "npm install",
    "start": "http-server -a localhost -p 8000 -c-1 ./app",
    "pretest": "npm install",
    "test": "karma start karma.conf.js",
    "test-single-run": "karma start karma.conf.js --single-run",
    "preupdate-webdriver": "npm install",
    "update-webdriver": "webdriver-manager update",
    "preprotractor": "npm run update-webdriver",
    "protractor": "protractor e2e-tests/protractor.conf.js",
    "update-index-async": "node -e \"var fs=require('fs'),indexFile='app/index-async.html',loaderFile='app/bower_components/angular-loader/angular-loader.min.js',loaderText=fs.readFileSync(loaderFile,'utf-8').split(/sourceMappingURL=angular-loader.min.js.map/).join('sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map'),indexText=fs.readFileSync(indexFile,'utf-8').split(/\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/).join('//@@NG_LOADER_START@@\\n'+loaderText+'    //@@NG_LOADER_END@@');fs.writeFileSync(indexFile,indexText);\""
  },
  "dependencies": {
    "@angular/common": "^4.4.4",
    "@angular/compiler": "^4.4.4",
    "@angular/core": "^4.4.4",
    "@angular/forms": "^4.4.4",
    "@angular/http": "^4.4.4",
    "@angular/platform-browser": "^4.4.4",
    "@angular/platform-browser-dynamic": "^4.4.4",
    "@angular/router": "^4.4.4",
    "angular-in-memory-web-api": "^0.5.0",
    "angular-route": "^1.6.6",
    "bootstrap": "^3.3.7",
    "font-awesome": "^4.7.0",
    "rxjs": "^5.4.3",
    "ts-node": "^3.3.0",
    "typescript": "^2.5.3",
    "typings": "^2.1.1",
    "zone.js": "^0.8.18"
  }
}

tsconfig.json

  {
     "compilerOptions": {
        "module": "system",
        "removeComments": true,
        "preserveConstEnums": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "sourceMap": true,
        "inlineSources": true,
        "target": "es5"

     },
     "compileOnSave": false,
     // Points folders and file to exclude
     "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
     ]
  }

typings.json

  {  
     "ambientDependencies": {  
        "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",  
        "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"  
     }  
  }  

1 个答案:

答案 0 :(得分:6)

您正在使用的TypeScript版本(2.5.3)与 2017.1.1 中提供的TypeScript服务集成不兼容。该问题是由服务API(https://github.com/Microsoft/TypeScript/issues/15433)中的重大更改引起的。

WEB-26641已在 2017.1.3 中修复,因此它与最高2.4的所有TypeScript版本兼容。 但2.5.x增加了更多的突破性变化。因此,如果您需要将IDEA与TypeScript 2.5.3一起使用,请确保更新到最新的IDEA版本。