unknownutil icon indicating copy to clipboard operation
unknownutil copied to clipboard

Deprecate `name` and `message` options of `assert` and `ensure`

Open lambdalisue opened this issue 1 year ago • 1 comments

If @core/errorutil offers error alteration functions as proposed in https://github.com/jsr-core/errorutil/issues/3, I believe we can deprecate the name and message options in assert and ensure.

I'd like to deprecate these options due to issue #121. Additionally, I'd like to deprecate setAssertMessageFactory (and its related functions) to simplify the overall implementation.

Before proceeding, I'd like to gauge how many users currently rely on these functionalities and whether they are open to migrating their code to the solution mentioned in the issue.

lambdalisue avatar Aug 13 '24 19:08 lambdalisue

import { assert, is } from "@core/unknownutil";
import { alter } from "@core/errorutil";

const v: unknown = "";

alter(() => assert(v, is.Number), new TypeError("v must be number"));
// TypeError instead of AssertError

lambdalisue avatar Aug 21 '24 21:08 lambdalisue