我在 Angular 2 中使用 WebRTC。
在 TypeScript 1.x 中,我可以成功使用它。
const peerConnection = new RTCPeerConnection(configuration, null);
但是在更新到 TypeScript 2.x 之后,我的终端出现了这个错误:
error TS2304: Cannot find name 'RTCPeerConnection'.
我已经执行了 npm install --save-dev @types/webrtc
,我的 IDE WebStorm 已经正确地将它链接到 RTCPeerConnection
的类型。
RTCPeerConnection
的输入在/my-project/node_modules/@types/webrtc/RTCPeerConnection.d.ts
我的tsconfig.json 文件:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"module": "commonjs",
"removeComments": true,
"sourceMap": true,
"lib": ["es6", "dom"]
},
"include": [
"node_modules/@types/**/*.d.ts",
"src/**/*.ts"
],
"exclude": [
"node_modules",
"!node_modules/@types/**/*.d.ts"
],
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
我怎样才能正确地做到这一点?
最佳答案
关于angular - 错误 TS2304 : Cannot find name 'RTCPeerConnection' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38908860/