Hongbo Miao Hongbo Miao - 11 months ago 127
TypeScript Question

error TS2304: Cannot find name 'RTCPeerConnection'

I am using WebRTC in Angular 2.

In TypeScript 1.x, I can use this successfully.

const peerConnection = new RTCPeerConnection(configuration, null);

But after updating to TypeScript 2.x, I got this error in my terminal:

error TS2304: Cannot find name 'RTCPeerConnection'.

I already did
npm install --save-dev @types/webrtc
, and my IDE WebStorm already link it to the typing of

Typing of
is in /my-project/node_modules/@types/webrtc/RTCPeerConnection.d.ts

My tsconfig.json file:

"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"module": "commonjs",
"removeComments": true,
"sourceMap": true,
"lib": ["es6", "dom"]
"include": [
"exclude": [
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false

How can I do it correctly? Thanks


@types/webrtc is a global type definition. Add

"types": [

to your compilerOptions. The types option is mentioned here.