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:
Andrew Casey
2018-09-25 10:50:20 -07:00
committed by GitHub
8 changed files with 95 additions and 0 deletions
+15
View File
@@ -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
+16
View File
@@ -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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+17
View File
@@ -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
+16
View File
@@ -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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }