1 declare module 'assert' {
2 function assert(value: any, message?: string | Error): asserts value;
4 class AssertionError implements Error {
10 generatedMessage: boolean;
11 code: 'ERR_ASSERTION';
13 constructor(options?: {
18 // tslint:disable-next-line:ban-types
19 stackStartFn?: Function;
23 type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
25 function fail(message?: string | Error): never;
26 /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
30 message?: string | Error,
32 // tslint:disable-next-line:ban-types
33 stackStartFn?: Function,
35 function ok(value: any, message?: string | Error): asserts value;
36 /** @deprecated since v9.9.0 - use strictEqual() instead. */
37 function equal(actual: any, expected: any, message?: string | Error): void;
38 /** @deprecated since v9.9.0 - use notStrictEqual() instead. */
39 function notEqual(actual: any, expected: any, message?: string | Error): void;
40 /** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
41 function deepEqual(actual: any, expected: any, message?: string | Error): void;
42 /** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
43 function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
44 function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
45 function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
46 function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
47 function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
49 function throws(block: () => any, message?: string | Error): void;
50 function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
51 function doesNotThrow(block: () => any, message?: string | Error): void;
52 function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
54 function ifError(value: any): asserts value is null | undefined;
56 function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
58 block: (() => Promise<any>) | Promise<any>,
59 error: AssertPredicate,
60 message?: string | Error,
62 function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
63 function doesNotReject(
64 block: (() => Promise<any>) | Promise<any>,
65 error: AssertPredicate,
66 message?: string | Error,
69 function match(value: string, regExp: RegExp, message?: string | Error): void;
70 function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
84 (value: any, message?: string | Error): asserts value;
85 equal: typeof strictEqual;
86 notEqual: typeof notStrictEqual;
87 deepEqual: typeof deepStrictEqual;
88 notDeepEqual: typeof notDeepStrictEqual;
90 // Mapped types and assertion functions are incompatible?
91 // TS2775: Assertions require every name in the call target
92 // to be declared with an explicit type annotation.
94 strictEqual: typeof strictEqual;
95 deepStrictEqual: typeof deepStrictEqual;
96 ifError: typeof ifError;
97 strict: typeof strict;