mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
add standard-http-error typings
This commit is contained in:
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for standard-http-error 2.0
|
||||
// Project: https://github.com/moll/js-standard-http-error
|
||||
// Definitions by: Labat Robin <https://github.com/roblabat>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="standard-error" />
|
||||
|
||||
declare module 'standard-http-error' {
|
||||
import * as StandardError from 'standard-error';
|
||||
|
||||
const HttpError: HttpError.constructor;
|
||||
|
||||
namespace HttpError {
|
||||
interface constructor {
|
||||
new (code: number | string, message?: string, props?: object): error;
|
||||
new (code: number | string, props?: object): error;
|
||||
[key: string]: number | undefined;
|
||||
}
|
||||
|
||||
interface error extends StandardError.error {
|
||||
code: number;
|
||||
}
|
||||
}
|
||||
|
||||
export = HttpError;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as HttpError from 'standard-http-error';
|
||||
|
||||
let error = new HttpError(200); //$ExpectType HttpError.error
|
||||
|
||||
error.code; //$ExpectType number
|
||||
error.message; //$ExpectType string
|
||||
error.name; //$ExpectType string
|
||||
error.stack; //$ExpectType string
|
||||
|
||||
error = new HttpError(200, 'test'); //$ExpectType HttpError.error
|
||||
error = new HttpError('OK', 'test'); //$ExpectType HttpError.error
|
||||
error = new HttpError(200, 'test', { foo: 'bar' }); //$ExpectType HttpError.error
|
||||
|
||||
error.foo; //$ExpectType any
|
||||
|
||||
error = new HttpError(200, { message: 'test', foo: 'bar' }); //$ExpectType HttpError.error
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "standard-http-error-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user