Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
fregante opened this issue Dec 6, 2021 · 2 comments
Closed

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

fregante opened this issue Dec 6, 2021 · 2 comments

Comments

@fregante
Copy link

fregante commented Dec 6, 2021

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

@MartinJohns
Copy link
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.

@fregante
Copy link
Author

fregante commented Dec 6, 2021

This was suggested as a feature request already: #45602

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

@fregante fregante closed this as completed Dec 6, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants