// code 3.0.0 // https://github.com/hapijs/code/blob/v3.0.0/API.md declare module 'code' { export interface ComparisonOptions { prototype?: boolean } export interface ChainableAssertion { (): Expectation } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof type typeString = 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined' interface Newable { new(... args: any[]): R } export interface Expectation { // connecting words to make assertions more readable: a: Expectation an: Expectation and: Expectation at: Expectation be: Expectation have: Expectation in: Expectation to: Expectation // toggle a status flag for the current assertion: not: Expectation // inverses the expected result of any assertion once: Expectation // requires that inclusion matches appear only once in the provided value only: Expectation // requires that only the provided elements appear in the provided value part: Expectation // allows a partial match when asserting inclusion shallow: Expectation // performs a comparison using strict equality // types arguments: ChainableAssertion array: ChainableAssertion boolean: ChainableAssertion buffer: ChainableAssertion date: ChainableAssertion error: (type?: string, message?: string | RegExp) => Expectation function: ChainableAssertion number: ChainableAssertion regexp: ChainableAssertion string: ChainableAssertion object: ChainableAssertion // values true: ChainableAssertion false: ChainableAssertion null: ChainableAssertion undefined: ChainableAssertion include: (valueOrValues: T | T[] | {}) => Expectation includes: (valueOrValues: T | T[] | {}) => Expectation contain: (valueOrValues: T | T[] | {}) => Expectation contains: (valueOrValues: T | T[] | {}) => Expectation startWith: (value: string) => Expectation startsWith: (value: string) => Expectation endWith: (value: string) => Expectation endsWith: (value: string) => Expectation exist: ChainableAssertion empty: ChainableAssertion length: (value: number) => Expectation equal: (value: T, options?: ComparisonOptions) => Expectation above: (value: number) => Expectation least: (value: number) => Expectation below: (value: number) => Expectation most: (value: number) => Expectation within: (lower: number, upper: number) => Expectation between: (lower: number, upper: number) => Expectation about: (value: number, delta: number) => Expectation // semicolon to force vscode syntax highlighting to behave instanceof(type: Newable): Expectation; match: (regex: RegExp) => Expectation matches: (regex: RegExp) => Expectation satisfy: (validator: (T) => boolean) => Expectation satisfies: (validator: any) => Expectation throw: (type?: typeString, message?: string | RegExp) => Expectation throws: (type?: typeString, message?: string | RegExp) => Expectation } export function fail(message: string): void export function count(): number export function incomplete(): string[] export function thrownAt(error: Error): { filename: string, line: string, // No, really. column: string, // I can't even. } export function expect(value: T, prefix?: string): Expectation; export var settings: { truncateMessages?: boolean comparePrototypes?: boolean } }