找不到名称 'RTCSignalingState'

Cannot find name 'RTCSignalingState'

我在连接 RTCPeerConnection 时遇到编译时错误。

/node_modules/@types/webrtc/RTCPeerConnection.d.ts (316,30): Cannot find name 'RTCSignalingState'.

const servers = null;
this.pc1 = new RTCPeerConnection(servers);

我已经安装了 npm install --save-dev @types/webrtc 我需要安装什么新东西吗?

所以我终于解决了这个问题。 问题是版本。 npm webrtc 包版本应该与你的打字稿版本相匹配。 我使用的是 typescript 版本 2.0.3,webrtc 的等价版本是 0.0.21.