我在Angular 2中使用WebRTC。
在TypeScript 1.x中,我可以成功使用它。
const peerConnection = new RTCPeerConnection(configuration, null);
但在更新到TypeScript 2.x后,我的终端出现了这个错误:
错误TS2304:找不到名称'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
}
}
我该怎么做才能正确?