Skip to content

useUnknownInCatchVariables does not apply to Promise#catch() #47033

Closed
@fregante

Description

@fregante

Bug Report

🔎 Search Terms

promise promises catch method function any unknown useUnknownInCatchVariables

🕗 Version & Regression Information

All versions with flag, like 4.5.0, including 4.6.0-nightly

async function veryverynice() {
    fetch('').catch(error => {
        console.log(error)
    })

    try {
        await fetch('')
    } catch (error) {
        console.log(error)
    }
}

⏯ Playground Link

4.6.0-nightly playground link with relevant code

💻 Code

async function veryverynice() {
    fetch('').catch(error => { // any
        console.log(error);
    });

    try {
        await fetch('')
    } catch (error) { // unknown
        console.log(error);
    }
}

🙁 Actual behavior

error in promise.catch(error => {}) is of type any

🙂 Expected behavior

error in promise.catch(error => {}) is of type unknown

🍝 Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions