Angular2构建错误TS2305

时间:2016-12-21 20:01:56

标签: angular typescript protractor typescript-typings

我试图在一个.NET项目中运行一个angular2项目的构建(我认为这部分并不重要)。

构建项目时遇到以下错误。已经尝试删除typings目录然后执行typings安装而不做任何更改。

  

的package.json

{
  "name": "angular2project",
  "version": "1.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "ng lint",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor",
    "clean": "rimraf -- wwwroot",
    "postclean": "ng build",
    "prebuild": "npm run clean",
    "build": "dotnet build",
    "clean:prod": "rimraf -- wwwroot",
    "postclean:prod": "ng build --prod",
    "prebuild:prod": "npm run clean:prod",
    "build:prod": "dotnet publish -c release"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.0.0",
    "@angular/compiler": "~2.0.0",
    "@angular/core": "~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",
    "core-js": "^2.4.1",
    "ng2-datepicker": "^1.1.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.17",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-firefox-launcher": "^1.0.0",
    "karma-ie-launcher": "^1.0.0",
    "karma-jasmine": "^1.0.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "karma-safari-launcher": "^1.0.0",
    "protractor": "4.0.9",
    "rimraf": "^2.5.4",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  },
  "-vs-binding": {
    "BeforeBuild": [
      "build"
    ]
  }
}
  

角-cli.json

{
  "project": {
    "version": "1.0.0-beta.16",
    "name": "angular-admin"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "wwwroot",
      "assets": "assets",
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}
  

错误输出

1>------ Build started: Project: Angular2, Configuration: Debug Any CPU ------ 
1>C:\Angular2\e2e\base.po.ts(1,10): error TS2305: Build:Module ''protractor'' has no exported member 'browser'. 
1>C:\Angular2\e2e\base.po.ts(1,19): error TS2305: Build:Module ''protractor'' has no exported member 'element'. 
1>C:\Angular2\e2e\base.po.ts(1,28): error TS2305: Build:Module ''protractor'' has no exported member 'by'. 
1>C:\Angular2\e2e\base.po.ts(1,32): error TS2305: Build:Module ''protractor'' has no exported member 'ProtractorBrowser'. 
1>C:\Angular2\node_modules\@types\jasmine\index.d.ts(74,9): error TS2375: Build:Duplicate number index signature. 
1>C:\Angular2\node_modules\@types\jasmine\index.d.ts(129,9): error TS2374: Build:Duplicate string index signature. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(70,5): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'main' must be of type 'any', but here has type 'NodeModule'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(81,5): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'parent' must be of type 'any', but here has type 'NodeModule'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(82,5): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'children' must be of type 'any[]', but here has type 'NodeModule[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(102,6): error TS2300: Build:Duplicate identifier 'BufferEncoding'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(553,26): error TS2300: Build:Duplicate identifier 'Buffer'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(553,50): error TS2300: Build:Duplicate identifier 'SlowBuffer'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(597,5): error TS2309: Build:An export assignment cannot be used in a module with other exported elements. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(742,18): error TS2300: Build:Duplicate identifier 'Agent'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(797,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'addressType' must be of type 'string', but here has type 'number | "udp4" | "udp6"'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(800,18): error TS2300: Build:Duplicate identifier 'Worker'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(1281,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'SNICallback' must be of type '(servername: string) => any', but here has type '(servername: string, cb: (err: Error, ctx: SecureContext) => any) => any'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(1481,17): error TS2300: Build:Duplicate identifier 'CompleterResult'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(1518,18): error TS2300: Build:Duplicate identifier 'Script'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(2770,16): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'StringDecoder' must be of type 'new (encoding: string) => NodeStringDecoder', but here has type 'new (encoding?: string) => NodeStringDecoder'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(2821,18): error TS2300: Build:Duplicate identifier 'TLSSocket'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3018,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'pfx' must be of type 'any', but here has type 'string | Buffer[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3019,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'key' must be of type 'any', but here has type 'string | any[] | string[] | Buffer'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3021,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'cert' must be of type 'any', but here has type 'string | string[] | Buffer | Buffer[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3022,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'ca' must be of type 'any', but here has type 'string | string[] | Buffer | Buffer[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3023,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'crl' must be of type 'any', but here has type 'string | string[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3025,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'honorCipherOrder' must be of type 'any', but here has type 'boolean'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3028,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'NPNProtocols' must be of type 'any', but here has type 'string[] | Buffer'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3029,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'SNICallback' must be of type '(servername: string) => any', but here has type '(servername: string, cb: (err: Error, ctx: SecureContext) => any) => any'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3045,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'key' must be of type 'string | Buffer', but here has type 'string | string[] | Buffer | Buffer[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3047,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'cert' must be of type 'string | Buffer', but here has type 'string | string[] | Buffer | Buffer[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3048,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'ca' must be of type '(string | Buffer)[]', but here has type 'string | Buffer | (string | Buffer)[]'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3287,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'padding' must be of type 'any', but here has type 'number'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3292,9): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'padding' must be of type 'any', but here has type 'number'. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3550,5): error TS2309: Build:An export assignment cannot be used in a module with other exported elements. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3633,5): error TS2300: Build:Duplicate identifier 'export='. 
1>C:\Angular2\node_modules\@types\node\index.d.ts(3655,18): error TS2300: Build:Duplicate identifier 'Domain'. 
1>C:\Angular2\node_modules\protractor\built\browser.d.ts(2,76): error TS2305: Build:Module ''selenium-webdriver'' has no exported member 'Options'. 
1>C:\Angular2\node_modules\protractor\built\browser.d.ts(2,116): error TS2305: Build:Module ''selenium-webdriver'' has no exported member 'TargetLocator'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(4,39): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(5,27): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(6,25): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(7,37): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(8,25): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(9,29): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(10,47): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(11,35): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\node_modules\protractor\built\locators.d.ts(12,31): error TS2304: Build:Cannot find name 'By'. 
1>C:\Angular2\src\app\app.service.ts(2,26): error TS2307: Build:Cannot find module 'angular2-hmr'. 
1>C:\Angular2\src\main.browser.ts(1,10): error TS2305: Build:Module '"C:/Angular2/node_modules/@angular/platform-browser-dynamic/index"' has no exported member 'browserDynamicPlatform'. 
1>C:\Angular2\typings\globals\node\index.d.ts(78,6): error TS2300: Build:Duplicate identifier 'BufferEncoding'. 
1>C:\Angular2\typings\globals\node\index.d.ts(503,9): error TS2502: Build:'BuffType' is referenced directly or indirectly in its own type annotation. 
1>C:\Angular2\typings\globals\node\index.d.ts(504,9): error TS2502: Build:'SlowBuffType' is referenced directly or indirectly in its own type annotation. 
1>C:\Angular2\typings\globals\node\index.d.ts(505,26): error TS2300: Build:Duplicate identifier 'Buffer'. 
1>C:\Angular2\typings\globals\node\index.d.ts(505,50): error TS2300: Build:Duplicate identifier 'SlowBuffer'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(567,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(578,22): error TS2320: Build:Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(606,22): error TS2320: Build:Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(632,22): error TS2320: Build:Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'. 
1>C:\Angular2\typings\globals\node\index.d.ts(682,18): error TS2300: Build:Duplicate identifier 'Agent'. 
1>C:\Angular2\typings\globals\node\index.d.ts(727,18): error TS2300: Build:Duplicate identifier 'Worker'. 
1>C:\Angular2\typings\globals\node\index.d.ts(980,22): error TS2300: Build:Duplicate identifier 'CompleterResult'. 
1>C:\Angular2\typings\globals\node\index.d.ts(1020,18): error TS2300: Build:Duplicate identifier 'Script'. 
1>C:\Angular2\typings\globals\node\index.d.ts(1298,22): error TS2320: Build:Interface 'Server' cannot simultaneously extend types 'Socket' and 'EventEmitter'. 
1>C:\Angular2\typings\globals\node\index.d.ts(1861,18): error TS2300: Build:Duplicate identifier 'TLSSocket'. 
1>C:\Angular2\typings\globals\node\index.d.ts(2159,18): error TS2420: Build:Class 'Readable' incorrectly implements interface 'ReadableStream'. 
1>C:\Angular2\typings\globals\node\index.d.ts(2196,18): error TS2420: Build:Class 'Duplex' incorrectly implements interface 'ReadWriteStream'. 
1>C:\Angular2\typings\globals\node\index.d.ts(2210,18): error TS2420: Build:Class 'Transform' incorrectly implements interface 'ReadWriteStream'. 
1>C:\Angular2\typings\globals\node\index.d.ts(2301,5): error TS2300: Build:Duplicate identifier 'export='. 
1>C:\Angular2\typings\globals\node\index.d.ts(2323,18): error TS2300: Build:Duplicate identifier 'Domain'. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

1 个答案:

答案 0 :(得分:1)

评论太长了:

我刚刚在angular-cli package.json上看了一下,我看到了一些差异。注意@ angular / compiler-cli的导入。这是一个猜测,但“编译器”和所有类型的问题可能是相关的。也许你的版本是旧的/关闭的(我在你的脚本@ angular / compiler而不是compiler-cli等中看到)。

(更改帖子以包含整个package.json内容):

{{1}}