mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
fix tests
This commit is contained in:
20
types/standard-error/index.d.ts
vendored
20
types/standard-error/index.d.ts
vendored
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
25
types/standard-http-error/index.d.ts
vendored
25
types/standard-http-error/index.d.ts
vendored
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user