Type definitions for http-assert (#13801)

* Type definitions for http-assert

* update http-assert
This commit is contained in:
jKey Lu
2017-01-06 08:17:39 -08:00
committed by Andy
parent 1883c3453f
commit ced2d7864b
4 changed files with 84 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
import * as httpAssert from 'http-assert';
import { HttpError } from 'http-errors';
try {
httpAssert.equal('hello', 'hello');
httpAssert(false, 401, 'authentication failed');
} catch(err) {
console.log((<HttpError>err).status);
console.log((<HttpError>err).message);
console.log((<HttpError>err).expose);
}
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for http-assert 1.2
// Project: https://github.com/jshttp/http-assert
// Definitions by: jKey Lu <https://github.com/jkeylu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
declare function assert(value: any, status?: number, msg?: string, opts?: {}): void;
declare namespace assert {
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
function equal<T>(a: T, b: T, status?: number, msg?: string, opts?: {}): void;
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
function notEqual<T>(a: T, b: T, status?: number, msg?: string, opts?: {}): void;
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
function strictEqual<T>(a: T, b: T, status?: number, msg?: string, opts?: {}): void;
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
function notStrictEqual<T>(a: T, b: T, status?: number, msg?: string, opts?: {}): void;
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
function deepEqual<T>(a: T, b: T, status?: number, msg?: string, opts?: {}): void;
/**
* @param {number} [status] the status code
* @param {string} [msg] the message of the error, defaulting to node's text for that status code
* @param {object} [opts] custom properties to attach to the error object
*/
function notDeepEqual<T>(a: T, b: T, status?: number, msg?: string, opts?: {}): void;
}
export = assert;
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"http-assert-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }