0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00
astro/.changeset/nasty-poems-juggle.md
Ben Holmes 08baf56f32
Actions: expand isInputError to accept unknown (#11439)
* feat: allow type `unknown` on `isInputError`

* chore: move ErrorInferenceObject to internal utils

* chore: changeset

* deps: expect-type

* feat: first types test

* chore: add types test to general test command

* refactor: use describe and it for organization
2024-07-09 15:54:49 -04:00

384 B

astro
patch

Expands the isInputError() utility from astro:actions to accept errors of any type. This should now allow type narrowing from a try / catch block.

// example.ts
import { actions, isInputError } from 'astro:actions';

try {
  await actions.like(new FormData());
} catch (error) {
  if (isInputError(error)) {
    console.log(error.fields);
  }
}