37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
export declare class InvariantError extends Error {
|
|
constructor(message: string);
|
|
}
|
|
/**
|
|
* Provide a condition and if that condition is falsey, this throws an error
|
|
* with the given message.
|
|
*
|
|
* inspired by invariant from 'tiny-invariant' except will still include the
|
|
* message in production.
|
|
*
|
|
* @example
|
|
* invariant(typeof value === 'string', `value must be a string`)
|
|
*
|
|
* @param condition The condition to check
|
|
* @param message The message to throw (or a callback to generate the message)
|
|
* @param responseInit Additional response init options if a response is thrown
|
|
*
|
|
* @throws {InvariantError} if condition is falsey
|
|
*/
|
|
export declare function invariant(condition: any, message: string | (() => string)): asserts condition;
|
|
/**
|
|
* Provide a condition and if that condition is falsey, this throws a 400
|
|
* Response with the given message.
|
|
*
|
|
* inspired by invariant from 'tiny-invariant'
|
|
*
|
|
* @example
|
|
* invariantResponse(typeof value === 'string', `value must be a string`)
|
|
*
|
|
* @param condition The condition to check
|
|
* @param message The message to throw (or a callback to generate the message)
|
|
* @param responseInit Additional response init options if a response is thrown
|
|
*
|
|
* @throws {Response} if condition is falsey
|
|
*/
|
|
export declare function invariantResponse(condition: any, message: string | (() => string), responseInit?: ResponseInit): asserts condition;
|