fix(ses): Add assert.error options bag to type definition
Fixes
MODIFY
packages/ses-types-test/validation.ts
packages/ses-types-test/validation.ts
@@ -218,11 +218,19 @@ assert.note(new Error('nothing to see here'), X`except this ${q('detail')}`);
X`canst thou string?`.toString();
-const f = (value: any) => {
+(value: any) => {
throw assert.error(X`details are ${q(value)}`);
};
-const g = (value: any) => {
+(value: any) => {
+ throw assert.error(X`details are ${q(value)}`, TypeError);
+};
+
+(value: any) => {
+ throw assert.error(X`details are ${q(value)}`, TypeError, { errorName: 'Nom de plum' });
+};
+
+(value: any) => {
assert.fail(X`details are ${q(value)}`);
};

MODIFY
packages/ses/NEWS.md
packages/ses/NEWS.md
User-visible changes in SES:
+# Next release
+
+- Fixes the type definition for assert.error so that the final options bag,
+ which may include `errorName`, checks correctly in TypeScript.
+
# 0.15.2 (2021-12-08)
- The `Removing...` messages that Lockdown emits when encountering unrecognized

MODIFY
packages/ses/index.d.ts
packages/ses/index.d.ts
@@ -89,6 +89,7 @@ export type DetailsToken = Record<any, never>
export type Details = string | DetailsToken
export interface AssertMakeErrorOptions {
+ errorName?: string,
}
type AssertTypeofBigint = (specimen: any, typeName: 'bigint', details?: Details) => asserts specimen is bigint;
@@ -119,7 +120,7 @@ interface ToStringable {
export interface Assert {
(value: any, details?: Details, errorConstructor?:ErrorConstructor): asserts value;
typeof: AssertTypeof,
- error(details?: Details, errorConstructor?:ErrorConstructor): Error;
+ error(details?: Details, errorConstructor?:ErrorConstructor, options?:AssertMakeErrorOptions): Error;
fail(details?: Details, errorConstructor?:ErrorConstructor): never;
equal(left: any, right: any, details?: Details, errorConstructor?:ErrorConstructor): void;
string(specimen: any, details?: Details): asserts specimen is string;

fix(ses): Add assert.error options bag to type definition (#978)

Fixes #977