UNPKG

2.9 kBTypeScriptView Raw
1// Type definitions for power-assert 1.5
2// Project: https://github.com/twada/power-assert
3// Definitions by: vvakame <https://github.com/vvakame>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 3.7
6
7// copy from assert external module in node.d.ts
8
9import * as empower from "empower";
10import * as powerAssertFormatter from "power-assert-formatter";
11
12export = assert;
13export as namespace assert;
14
15declare function assert(value: unknown, message?: string): asserts value;
16declare namespace assert {
17 class AssertionError implements Error {
18 name: string;
19 message: string;
20 actual: unknown;
21 expected: unknown;
22 operator: string;
23 generatedMessage: boolean;
24
25 constructor(options?: {
26 // tslint:disable-next-line:no-redundant-undefined
27 message?: string | undefined;
28 actual?: unknown;
29 expected?: unknown;
30 // tslint:disable-next-line:no-redundant-undefined
31 operator?: string | undefined;
32 // tslint:disable-next-line:no-redundant-undefined
33 stackStartFunction?: () => void | undefined
34 });
35 }
36
37 function fail(actual?: unknown, expected?: unknown, message?: string, operator?: string): never;
38 function ok(value: unknown, message?: string): asserts value;
39 function equal(actual: unknown, expected: unknown, message?: string): void;
40 function notEqual(actual: unknown, expected: unknown, message?: string): void;
41 function deepEqual(actual: unknown, expected: unknown, message?: string): void;
42 function notDeepEqual(actual: unknown, expected: unknown, message?: string): void;
43 function strictEqual<T>(actual: unknown, expected: T, message?: string): asserts actual is T;
44 function notStrictEqual(actual: unknown, expected: unknown, message?: string): void;
45 function deepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
46 function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
47 const throws: {
48 (block: () => unknown, message?: string): void;
49 (block: () => unknown, error: (new () => object) | RegExp | ((err: unknown) => boolean), message?: string): void;
50 };
51 const doesNotThrow: {
52 (block: () => unknown, message?: string): void;
53 (block: () => unknown, error: (new () => object) | RegExp | ((err: any) => boolean), message?: string): void;
54 };
55 function ifError(value: unknown): asserts value is null | undefined;
56
57 const strict: typeof assert;
58
59 interface Options {
60 // tslint:disable-next-line:no-redundant-undefined
61 assertion?: empower.Options | undefined;
62 // tslint:disable-next-line:no-redundant-undefined
63 output?: powerAssertFormatter.Options | undefined;
64 }
65
66 function customize(options: Options): typeof assert;
67}
68
\No newline at end of file