add standard-error typings

This commit is contained in:
Robin Labat
2018-09-24 16:16:42 +02:00
parent adf4e18eef
commit 369b95cd66
4 changed files with 57 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
// 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
declare module 'standard-error' {
const StandardError: StandardError.constructor;
namespace StandardError {
interface constructor {
new (message: string, props?: object): error;
new (props: object): error;
}
interface error extends Error {
[key: string]: any;
}
}
export = StandardError;
}
@@ -0,0 +1,13 @@
import * as StandardError from 'standard-error';
let error = new StandardError('test'); //$ExpectType StandardError.error
error.message; //$ExpectType string
error.name; //$ExpectType string
error.stack; //$ExpectType string
error = new StandardError({ name: 'test', foo: 'bar' }); //$ExpectType StandardError.error
error.foo; //$ExpectType any
error = new StandardError('test', { foo: 'bar' }); //$ExpectType StandardError.error
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": 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" }