fix tests

This commit is contained in:
Robin Labat
2018-09-24 17:48:52 +02:00
parent 37f75f03f8
commit d12ded0d4a
4 changed files with 34 additions and 49 deletions

View File

@@ -3,19 +3,13 @@
// Definitions by: Labat Robin <https://github.com/roblabat>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'standard-error' {
const StandardError: StandardError.constructor;
// TypeScript Version: 2.2
namespace StandardError {
interface constructor {
new (message: string, props?: object): error;
new (props: object): error;
}
export = StandardError;
interface error extends Error {
[key: string]: any;
}
}
declare class StandardError extends Error {
[key: string]: any;
export = StandardError;
}
constructor(message: string, props?: any);
constructor(props: any);
}

View File

@@ -1,13 +1,13 @@
import * as StandardError from 'standard-error';
import StandardError = require('standard-error');
let error = new StandardError('test'); //$ExpectType StandardError.error
let error = new StandardError('test'); // $ExpectType StandardError
error.message; //$ExpectType string
error.name; //$ExpectType string
error.stack; //$ExpectType string
error.message; // $ExpectType string
error.name; // $ExpectType string
error.stack; // $ExpectType string | undefined
error = new StandardError({ name: 'test', foo: 'bar' }); //$ExpectType StandardError.error
error = new StandardError({ name: 'test', foo: 'bar' }); // $ExpectType StandardError
error.foo; //$ExpectType any
error.foo; // $ExpectType any
error = new StandardError('test', { foo: 'bar' }); //$ExpectType StandardError.error
error = new StandardError('test', { foo: 'bar' }); // $ExpectType StandardError

View File

@@ -3,24 +3,15 @@
// Definitions by: Labat Robin <https://github.com/roblabat>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="standard-error" />
// TypeScript Version: 2.2
declare module 'standard-http-error' {
import * as StandardError from 'standard-error';
import StandardError = require('standard-error');
const HttpError: HttpError.constructor;
export = HttpError;
namespace HttpError {
interface constructor {
new (code: number | string, message?: string, props?: object): error;
new (code: number | string, props?: object): error;
[key: string]: number | undefined;
}
declare class HttpError extends StandardError {
code: number;
interface error extends StandardError.error {
code: number;
}
}
export = HttpError;
}
constructor(code: number | string, message?: string, props?: object);
constructor(code: number | string, props?: object);
}

View File

@@ -1,16 +1,16 @@
import * as HttpError from 'standard-http-error';
import HttpError = require('standard-http-error');
let error = new HttpError(200); //$ExpectType HttpError.error
let error = new HttpError(200); // $ExpectType HttpError
error.code; //$ExpectType number
error.message; //$ExpectType string
error.name; //$ExpectType string
error.stack; //$ExpectType string
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
error = new HttpError('OK', 'test'); //$ExpectType HttpError.error
error = new HttpError(200, 'test', { foo: 'bar' }); //$ExpectType HttpError.error
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.foo; // $ExpectType any
error = new HttpError(200, { message: 'test', foo: 'bar' }); //$ExpectType HttpError.error
error = new HttpError(200, { message: 'test', foo: 'bar' }); // $ExpectType HttpError