declare module 'meteor/check' { /** * The namespace for all Match types and methods. */ namespace Match { interface Matcher { _meteorCheckMatcherBrand: void; } // prettier-ignore export type Pattern = typeof String | typeof Number | typeof Boolean | typeof Object | typeof Function | (new (...args: any[]) => any) | undefined | null | string | number | boolean | // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type [Pattern] | {[key: string]: Pattern} | Matcher; // prettier-ignore export type PatternMatch = T extends Matcher ? U : T extends typeof String ? string : T extends typeof Number ? number : T extends typeof Boolean ? boolean : T extends typeof Object ? object : T extends typeof Function ? Function : T extends undefined | null | string | number | boolean ? T : T extends new (...args: any[]) => infer U ? U : // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type T extends [Pattern] ? Array> : T extends {[key: string]: Pattern} ? {[K in keyof T]: PatternMatch} : unknown; /** Matches any value. */ var Any: Matcher; /** Matches a signed 32-bit integer. Doesn’t match `Infinity`, `-Infinity`, or `NaN`. */ var Integer: Matcher; /** * Matches either `undefined`, `null`, or pattern. If used in an object, matches only if the key is not set as opposed to the value being set to `undefined` or `null`. This set of conditions * was chosen because `undefined` arguments to Meteor Methods are converted to `null` when sent over the wire. */ function Maybe(pattern: T): Matcher | undefined | null>; /** Behaves like `Match.Maybe` except it doesn’t accept `null`. If used in an object, the behavior is identical to `Match.Maybe`. */ function Optional(pattern: T): Matcher | undefined>; /** Matches an Object with the given keys; the value may also have other keys with arbitrary values. */ function ObjectIncluding(dico: T): Matcher>; /** Matches any value that matches at least one of the provided patterns. */ function OneOf(...patterns: T): Matcher>; /** * Calls the function condition with the value as the argument. If condition returns true, this matches. If condition throws a `Match.Error` or returns false, this fails. If condition throws * any other error, that error is thrown from the call to `check` or `Match.test`. */ function Where(condition: (val: any) => val is T): Matcher; function Where(condition: (val: any) => boolean): Matcher; /** * Returns true if the value matches the pattern. * @param value The value to check * @param pattern The pattern to match `value` against */ function test(value: any, pattern: T): value is PatternMatch; } /** * Check that a value matches a pattern. * If the value does not match the pattern, throw a `Match.Error`. * * Particularly useful to assert that arguments to a function have the right * types and structure. * @param value The value to check * @param pattern The pattern to match `value` against */ function check(value: any, pattern: T): asserts value is Match.PatternMatch; }