Hongbo Miao Hongbo Miao - 2 months ago 46x
TypeScript Question

error TS2339: Property 'catch' does not exist on type 'PromiseLike<void>'

I am using WebRTC in Angular 2.

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

.then(stream => {

.catch(error => {


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

error TS2339: Property 'catch' does not exist on type

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

Then I tried to install
npm install --save-dev @types/promise
(not sure whether should be this typing file or not), but I have no idea how to import.

How can I get rid of that error?


Promise and PromiseLike are part of the built-in declarations. They are limited to target: ES6, but you can include them in a ES5 target (where promises are already available, but not all ES6 features) by adding es2015.Promise to the lib compiler flag. For more information see Including built-in type declarations with --lib