mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-02 22:07:06 +00:00
Merge pull request #29160 from roblabat/standard-error
[standard-error][standard-http-error] add typings for standard-error and standard-http-error packages
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for standard-error 1.1
|
||||
// Project: https://github.com/moll/js-standard-error
|
||||
// Definitions by: Labat Robin <https://github.com/roblabat>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = StandardError;
|
||||
|
||||
declare class StandardError extends Error {
|
||||
[key: string]: any;
|
||||
|
||||
constructor(message: string, props?: any);
|
||||
constructor(props: any);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import StandardError = require('standard-error');
|
||||
|
||||
let error = new StandardError('test'); // $ExpectType StandardError
|
||||
|
||||
error.message; // $ExpectType string
|
||||
error.name; // $ExpectType string
|
||||
error.stack; // $ExpectType string | undefined
|
||||
|
||||
error = new StandardError({ name: 'test', foo: 'bar' }); // $ExpectType StandardError
|
||||
|
||||
error.foo; // $ExpectType any
|
||||
|
||||
error = new StandardError('test', { foo: 'bar' }); // $ExpectType StandardError
|
||||
@@ -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-error-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// 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
|
||||
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import StandardError = require('standard-error');
|
||||
|
||||
export = HttpError;
|
||||
|
||||
declare class HttpError extends StandardError {
|
||||
code: number;
|
||||
|
||||
constructor(code: number | string, message?: string, props?: object);
|
||||
constructor(code: number | string, props?: object);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import HttpError = require('standard-http-error');
|
||||
|
||||
let error = new HttpError(200); // $ExpectType HttpError
|
||||
|
||||
error.code; // $ExpectType number
|
||||
error.message; // $ExpectType string
|
||||
error.name; // $ExpectType string
|
||||
error.stack; // $ExpectType string | undefined
|
||||
|
||||
error = new HttpError(200, 'test'); // $ExpectType HttpError
|
||||
error = new HttpError('OK', 'test'); // $ExpectType HttpError
|
||||
error = new HttpError(200, 'test', { foo: 'bar' }); // $ExpectType HttpError
|
||||
|
||||
error.foo; // $ExpectType any
|
||||
|
||||
error = new HttpError(200, { message: 'test', foo: 'bar' }); // $ExpectType HttpError
|
||||
@@ -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