From 6077d61e735e7dbfda2919be090fb30e28034c76 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 7 Oct 2021 12:17:33 +0200 Subject: [PATCH] errors: added changeset for new assertion helpers Signed-off-by: Patrik Oldsberg --- .changeset/real-mice-beg.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/real-mice-beg.md diff --git a/.changeset/real-mice-beg.md b/.changeset/real-mice-beg.md new file mode 100644 index 0000000000..bcb4f0ca9a --- /dev/null +++ b/.changeset/real-mice-beg.md @@ -0,0 +1,5 @@ +--- +'@backstage/errors': patch +--- + +Two new helpers have been added that make it easier to migrate to considering thrown errors to be of the type `unknown` in TypeScript. The helpers are `assertError` and `isError`, and can be called to make sure that an unknown value conforms to the shape of an `ErrorLike` object. The `assertError` function is a type-guard that throws in the case of a mismatch, while `isError` returns false.