github-pages-deploy-action/node_modules/make-error/index.d.ts

41 lines
932 B
TypeScript
Raw Normal View History

2020-03-31 20:42:07 +08:00
/**
* Create a new error constructor instance.
*/
2020-03-31 20:57:48 +08:00
declare function makeError(name: string): makeError.Constructor<makeError.BaseError>;
2020-03-31 20:42:07 +08:00
/**
* Set the constructor prototype to `BaseError`.
*/
2020-03-31 20:57:48 +08:00
declare function makeError<T extends Error>(super_: { new (...args: any[]): T }): makeError.Constructor<T & makeError.BaseError>;
2020-03-31 20:42:07 +08:00
/**
* Create a specialized error instance.
*/
2020-03-31 20:57:48 +08:00
declare function makeError<T extends Error, K>(name: string | Function, super_: K): K & makeError.SpecializedConstructor<T>;
2020-03-31 20:42:07 +08:00
2020-03-31 20:57:48 +08:00
declare module makeError {
2020-03-31 20:42:07 +08:00
/**
* Use with ES2015+ inheritance.
*/
2020-03-31 20:57:48 +08:00
export class BaseError implements Error {
2020-03-31 20:42:07 +08:00
message: string;
name: string;
stack: string;
constructor(message?: string);
}
2020-03-31 20:57:48 +08:00
export interface Constructor <T> {
2020-03-31 20:42:07 +08:00
new (message?: string): T;
2020-03-31 20:57:48 +08:00
super_: any
prototype: T
2020-03-31 20:42:07 +08:00
}
2020-03-31 20:57:48 +08:00
export interface SpecializedConstructor <T> {
super_: any
prototype: T
2020-03-31 20:42:07 +08:00
}
}
export = makeError;