VS code revert catch statement's parameter error: any or error: unknown to error only

28 views Asked by At

When try to run react app (react18 and typescirpt 4)

There is a terminal error

TS2339: Property 'error' does not exist on type 'unknown'.

try {


} catch (error: any) {
    // do something
}

try {


} catch (error: unknown) {
    // do something
}

try {


} catch (error: CustError) {
    // do something
}

VScode will instantly revert to on save

try {


} catch (error) {
    // do something
}

Is it a way to get around with this?

0

There are 0 answers