mattpocock / ts-error-translator

VSCode extension to turn TypeScript errors into plain English
https://ts-error-translator.vercel.app
2.35k stars 90 forks source link

Translation request for 1196 #295

Open machr opened 2 months ago

machr commented 2 months ago

Error Text

Catch clause variable type annotation must be 'any' or 'unknown' if specified.

Supporting Information

Working on typing an AxiosError in a try/catch block.

The code block in question is

try {
        const { data: newSubrecipeId } = await axios.post(
            `/{SAMPLE_REST_API_ENDPOINT}`,
        );
        router.push({
            name: 'EditSubrecipe',
            params: { id: newSubrecipeId },
        });
        // error.value[id] = '';
    } catch (err: AxiosError) {. <--- This line would be great to have translated. What does 'catch' expect 
        if (
            axios.isAxiosError(err) &&
            err.response &&
            err.response.status === 422 &&
            err.response.data
        ) {
            error.value[id] = err.response.data.message;
        } else {
            throw new Error('Something went wrong duplicating Subrecipe');

        }
    }

Update: Found some Documentation around the issue https://fettblog.eu/typescript-typing-catch-clauses/