Skip to content

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

Closed

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

Activity

  1. MartinJohns commented on Dec 6, 2021

    @MartinJohns
    Contributor

    This is not a bug. The flag is not supposed to change the type of the catch method.

    This was suggested as a feature request already: #45602. This was mentioned in the PR you linked.

  2. fregante commented on Dec 6, 2021

    @fregante
    Author

    This was suggested as a feature request already: #45602

    I was literally writing a comment about that 😅 sorry for the duplicate

  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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