gpt4 book ai didi

angular - @types/webrtc 的 typescript 错误

转载 作者:太空狗 更新时间:2023-10-29 18:31:14 32 4
gpt4 key购买 nike

在我的 Angular 2 项目中,我尝试使用 typescript 和 @types/webrtc。@types/webrtc 的版本是 0.0.21如果我使用任何高于 2.1.5 的 typescript 版本,我会收到很多 webrtc 的编译错误。

这是我的 package.json 文件:

{
"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"
}
}

这里是编译错误:

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'.

最佳答案

目前还没有官方的解决方案(或者,至少,我还没有找到)。但是有一个很好的解决方法,它可以让您继续工作!

正如您在此 issue 中看到的那样在 DefinitelyTyped Github web 中,Varius 建议在 tsconfig.json 中的 compilerOptions 上添加一个很棒的选项,以避免库检查。

"compilerOptions": {
"skipLibCheck": true
}

我希望它对你有用,对我也有用!

关于angular - @types/webrtc 的 typescript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44005415/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com