import { assertIs } from "https://deno.land/x/typeguardkit@0.33.0/mod.ts";
assertIs
wraps asserter
with an assertion signature so value
can be
narrowed to Type
. If asserter.assert
throws an error, it will bubble up.
Otherwise, assertIs
will not return a value, but after calling it, value
will be narrowed to Type
.
Example:
import { _string, assertIs } from "typeguardkit";
function handleUnknown(x: unknown) {
assertIs(_string, x, "x");
handleString(x);
}
function handleString(x: string) {};