angular - Typescript-fel med @types/webrtc
I mitt Angular 2-projekt försöker jag använda TypeScript och @types/webrtc. @types/webrtc är på version 0.0.21. Om jag använder någon TypeScript-version högre än 2.1.5 får jag många kompileringsfel för webrtc.
Här är min package.json-fil:
{
"name": "d3",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/cli": "1.0.3",
"@angular/common": "4.1.2",
"@angular/animations": "4.1.2",
"@angular/compiler": "4.1.2",
"@angular/compiler-cli":"4.1.2",
"@angular/core": "4.1.2",
"@angular/forms": "4.1.2",
"@angular/http": "4.1.2",
"@angular/platform-browser": "4.1.2",
"@angular/platform-browser-dynamic": "4.1.2",
"@angular/router": "4.1.2",
"@angular/material": "2.0.0-beta.5",
"@types/hammerjs": "2.0.34",
"hammerjs": "2.0.8",
"angular2-material-datepicker": "0.5.0",
"core-js": "2.4.1",
"primeng": "4.0.1",
"rxjs": "5.4.0",
"ts-helpers": "1.1.2",
"zone.js": "0.8.10"
},
"devDependencies": {
"@types/jasmine": "2.5.47",
"@types/node": "7.0.18",
"@types/webrtc": "0.0.21",
"angular2-template-loader": "0.6.2",
"codelyzer": "3.0.1",
"jasmine-core": "2.6.1",
"jasmine-spec-reporter": "4.1.0",
"karma": "1.7.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.0",
"karma-remap-istanbul": "0.6.0",
"protractor": "5.1.2",
"ts-node": "3.0.4",
"tslint": "5.2.0",
"typescript": "2.3.2",
"webdriver-manager": "12.0.6"
}
}
Här är kompileringsfelen:
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (31,6): Duplicate identifier 'RTCSdpType'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (35,5): All declarations of 'type' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (41,14): All declarations of 'type' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (42,14): All declarations of 'sdp' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (49,6): Duplicate identifier 'RTCIceProtocol'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (52,6): Duplicate identifier 'RTCIceCandidateType'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (55,6): Duplicate identifier 'RTCIceTcpCandidateType'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (59,5): All declarations of 'candidate' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (66,14): All declarations of 'candidate' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (67,14): All declarations of 'sdpMid' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (68,14): All declarations of 'sdpMLineIndex' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (90,6): Duplicate identifier 'RTCSignalingState'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (93,6): Duplicate identifier 'RTCIceGatheringState'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (96,6): Duplicate identifier 'RTCIceConnectionState'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (113,6): Duplicate identifier 'RTCIceTransportPolicy'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (116,6): Duplicate identifier 'RTCBundlePolicy'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (122,6): Duplicate identifier 'RTCIceRole'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (125,6): Duplicate identifier 'RTCIceComponent'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (128,6): Duplicate identifier 'RTCIceTransportState'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (153,6): Duplicate identifier 'RTCDtlsTransportState'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (204,5): All declarations of 'maxFramerate' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (231,6): Duplicate identifier 'RTCDegradationPreference'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (401,6): Duplicate identifier 'RTCSessionDescriptionCallback'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (405,6): Duplicate identifier 'RTCPeerConnectionErrorCallback'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (409,6): Duplicate identifier 'RTCStatsCallback'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (432,14): All declarations of 'canTrickleIceCandidates' must have identical modifiers.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (438,5): Subsequent variable declarations must have the same type. Variable 'onnegotiationneeded' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (439,5): Subsequent variable declarations must have the same type. Variable 'onicecandidate' must be of type '(this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any', but here has type '(event: RTCPeerConnectionIceEvent) => void'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (441,5): Subsequent variable declarations must have the same type. Variable 'onsignalingstatechange' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (442,5): Subsequent variable declarations must have the same type. Variable 'oniceconnectionstatechange' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (443,5): Subsequent variable declarations must have the same type. Variable 'onicegatheringstatechange' must be of type '(this: RTCPeerConnection, ev: Event) => any', but here has type 'EventHandler'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (491,13): Subsequent variable declarations must have the same type. Variable 'RTCPeerConnection' must be of type '{ new (configuration: RTCConfiguration): RTCPeerConnection; prototype: RTCPeerConnection; }', but here has type 'RTCPeerConnectionStatic'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (492,13): Subsequent variable declarations must have the same type. Variable 'RTCSessionDescription' must be of type '{ new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; prototype: RTCSes...', but here has type 'RTCSessionDescriptionStatic'.
ERROR in objs/node_modules/@types/webrtc/RTCPeerConnection.d.ts (493,13): Subsequent variable declarations must have the same type. Variable 'RTCIceCandidate' must be of type '{ new (candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; prototype: RTCIceCandidate; }', but here has type 'RTCIceCandidateStatic'.
ERROR in objs/node_modules/@types/webrtc/MediaStream.d.ts (104,14): Duplicate identifier 'MediaStreamTrackState'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (834,5): All declarations of 'candidate' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (995,5): All declarations of 'maxFramerate' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (1040,5): All declarations of 'type' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (9048,5): All declarations of 'candidate' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (9049,5): All declarations of 'sdpMLineIndex' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (9050,5): All declarations of 'sdpMid' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (9147,14): All declarations of 'canTrickleIceCandidates' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (9241,5): All declarations of 'sdp' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (9242,5): All declarations of 'type' must have identical modifiers.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (14254,11): Duplicate identifier 'RTCSessionDescriptionCallback'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (14257,11): Duplicate identifier 'RTCPeerConnectionErrorCallback'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (14260,11): Duplicate identifier 'RTCStatsCallback'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15011,6): Duplicate identifier 'MediaStreamTrackState'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15023,6): Duplicate identifier 'RTCBundlePolicy'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15024,6): Duplicate identifier 'RTCDegradationPreference'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15026,6): Duplicate identifier 'RTCDtlsTransportState'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15027,6): Duplicate identifier 'RTCIceCandidateType'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15028,6): Duplicate identifier 'RTCIceComponent'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15029,6): Duplicate identifier 'RTCIceConnectionState'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15032,6): Duplicate identifier 'RTCIceGatheringState'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15033,6): Duplicate identifier 'RTCIceProtocol'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15034,6): Duplicate identifier 'RTCIceRole'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15035,6): Duplicate identifier 'RTCIceTcpCandidateType'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15036,6): Duplicate identifier 'RTCIceTransportPolicy'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15037,6): Duplicate identifier 'RTCIceTransportState'.
ERROR in objs/node_modules/typescript/lib/lib.dom.d.ts (15038,6): Duplicate identifier 'RTCSdpType'.
Svar #1
För närvarande finns det ingen officiell lösning (eller åtminstone har jag inte hittat den). Men det finns en bra lösning som gör att du kan fortsätta arbeta!
Som du kan se i detta problem på DefinitelyTyped Github-webb, föreslår Varius att lägga till ett fantastiskt alternativ över compilerOptions i din tsconfig.json för att undvika biblioteksgranskning.
"compilerOptions": {
"skipLibCheck": true
}
Jag hoppas att det fungerar för dig lika bra som det fungerar för mig!
Svar #2
I din tsconfig.json lägg till detta:
{
"compilerOptions": {
"typeRoots": [
"node_modules/@types"
],
}
