Skip to content

Property 'catch' does not exist on type 'PromiseLike' #13947

Closed
@basarat

Description

@basarat

TypeScript Version: nightly today

Code

fetch('flowers.jpg')
    .then(function(response) {
        if (response.ok) {
            return response.blob();
        }
        throw new Error('Network response was not ok.');
    })
    .catch(function(error) {
        console.log('There has been a problem with your fetch operation: ' + error.message);
    });

Expected behavior:

Compile without error. Example taken from https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Checking_that_the_fetch_was_successful

Actual behavior:

Errors:

/Users/syedb/REPOS/alm/src/server/workers/external/npmService.ts:8 Property 'catch' does not exist on type 'PromiseLike<Blob>'.

Note: The whatwg definitions from definitely typed worked fine. The version pulling into lib.d.ts lib:['es6'] is broken slightly as shown 🌹

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions