|
| 1 | +declare module "assert" { |
| 2 | + function assert(value: any, message?: string | Error): asserts value; |
| 3 | + namespace assert { |
| 4 | + class AssertionError implements Error { |
| 5 | + name: string; |
| 6 | + message: string; |
| 7 | + actual: any; |
| 8 | + expected: any; |
| 9 | + operator: string; |
| 10 | + generatedMessage: boolean; |
| 11 | + code: 'ERR_ASSERTION'; |
| 12 | + |
| 13 | + constructor(options?: { |
| 14 | + message?: string; actual?: any; expected?: any; |
| 15 | + operator?: string; stackStartFn?: Function |
| 16 | + }); |
| 17 | + } |
| 18 | + |
| 19 | + type AssertPredicate = RegExp | (new() => object) | ((thrown: any) => boolean) | object | Error; |
| 20 | + |
| 21 | + function fail(message?: string | Error): never; |
| 22 | + /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */ |
| 23 | + function fail(actual: any, expected: any, message?: string | Error, operator?: string, stackStartFn?: Function): never; |
| 24 | + function ok(value: any, message?: string | Error): asserts value; |
| 25 | + /** @deprecated since v9.9.0 - use strictEqual() instead. */ |
| 26 | + function equal(actual: any, expected: any, message?: string | Error): void; |
| 27 | + /** @deprecated since v9.9.0 - use notStrictEqual() instead. */ |
| 28 | + function notEqual(actual: any, expected: any, message?: string | Error): void; |
| 29 | + /** @deprecated since v9.9.0 - use deepStrictEqual() instead. */ |
| 30 | + function deepEqual(actual: any, expected: any, message?: string | Error): void; |
| 31 | + /** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */ |
| 32 | + function notDeepEqual(actual: any, expected: any, message?: string | Error): void; |
| 33 | + function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T; |
| 34 | + function notStrictEqual(actual: any, expected: any, message?: string | Error): void; |
| 35 | + function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T; |
| 36 | + function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void; |
| 37 | + |
| 38 | + function throws(block: () => any, message?: string | Error): void; |
| 39 | + function throws(block: () => any, error: AssertPredicate, message?: string | Error): void; |
| 40 | + function doesNotThrow(block: () => any, message?: string | Error): void; |
| 41 | + function doesNotThrow(block: () => any, error: RegExp | Function, message?: string | Error): void; |
| 42 | + |
| 43 | + function ifError(value: any): asserts value is null | undefined; |
| 44 | + |
| 45 | + function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>; |
| 46 | + function rejects(block: (() => Promise<any>) | Promise<any>, error: AssertPredicate, message?: string | Error): Promise<void>; |
| 47 | + function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>; |
| 48 | + function doesNotReject(block: (() => Promise<any>) | Promise<any>, error: RegExp | Function, message?: string | Error): Promise<void>; |
| 49 | + |
| 50 | + function match(value: string, regExp: RegExp, message?: string | Error): void; |
| 51 | + function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void; |
| 52 | + |
| 53 | + const strict: typeof assert; |
| 54 | + } |
| 55 | + |
| 56 | + export = assert; |
| 57 | +} |
0 commit comments