Instantly throws the message or error. strings are wrapped in an Error.
string
Error
Useful to throw early if something is expected to be defined using the ?? operator. Example:
??
const getX: () => number | undefinedconst x: number = getX() ?? throw_("expected x to be defined") Copy
const getX: () => number | undefinedconst x: number = getX() ?? throw_("expected x to be defined")
Optional
Instantly throws the message or error.
strings are wrapped in anError.Useful to throw early if something is expected to be defined using the
??operator. Example: