【发布时间】:2016-12-18 22:19:54
【问题描述】:
我在 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
}
}
我怎样才能正确地做到这一点?
【问题讨论】:
标签: angular typescript webrtc typescript2.0