diff --git a/types/standard-error/index.d.ts b/types/standard-error/index.d.ts new file mode 100644 index 0000000000..4bdf04c33e --- /dev/null +++ b/types/standard-error/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for standard-error 1.1 +// Project: https://github.com/moll/js-standard-error +// Definitions by: Labat Robin +// 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); +} diff --git a/types/standard-error/standard-error-tests.ts b/types/standard-error/standard-error-tests.ts new file mode 100644 index 0000000000..a5184da531 --- /dev/null +++ b/types/standard-error/standard-error-tests.ts @@ -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 diff --git a/types/standard-error/tsconfig.json b/types/standard-error/tsconfig.json new file mode 100644 index 0000000000..b0e6e23d4b --- /dev/null +++ b/types/standard-error/tsconfig.json @@ -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"] +} diff --git a/types/standard-error/tslint.json b/types/standard-error/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/standard-error/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/standard-http-error/index.d.ts b/types/standard-http-error/index.d.ts new file mode 100644 index 0000000000..9b95acebeb --- /dev/null +++ b/types/standard-http-error/index.d.ts @@ -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 +// 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); +} diff --git a/types/standard-http-error/standard-http-error-tests.ts b/types/standard-http-error/standard-http-error-tests.ts new file mode 100644 index 0000000000..0b430774d2 --- /dev/null +++ b/types/standard-http-error/standard-http-error-tests.ts @@ -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 diff --git a/types/standard-http-error/tsconfig.json b/types/standard-http-error/tsconfig.json new file mode 100644 index 0000000000..cc399408e1 --- /dev/null +++ b/types/standard-http-error/tsconfig.json @@ -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"] +} diff --git a/types/standard-http-error/tslint.json b/types/standard-http-error/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/standard-http-error/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }