[@types/node-fetch] Fix FetchError class definition (#40581)

* Fix FetchError class definition

* Add myself to "Definitions by" section of package header
This commit is contained in:
Alexandru Savin
2019-11-22 07:46:28 -08:00
committed by Sheetal Nandi
parent eaf62c8120
commit c5687bab45
2 changed files with 15 additions and 2 deletions
+6 -1
View File
@@ -9,6 +9,7 @@
// Brandon Wilson <https://github.com/wilsonianb>
// Steve Faulkner <https://github.com/southpolesteve>
// ExE Boss <https://github.com/ExE-Boss>
// Alex Savin <https://github.com/alexandrusavin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -148,9 +149,13 @@ export class Body {
timeout: number;
}
interface SystemError extends Error {
code?: string;
}
export class FetchError extends Error {
name: "FetchError";
constructor(message: string, type: string, systemError?: string);
constructor(message: string, type: string, systemError?: SystemError);
type: string;
code?: string;
errno?: string;
+9 -1
View File
@@ -158,7 +158,15 @@ function test_isRedirect() {
}
function test_FetchError() {
new FetchError("message", "type", "systemError");
new FetchError("message", "type", {
name: 'Error',
message: 'Error message',
code: "systemError",
});
new FetchError("message", "type", {
name: 'Error',
message: "Error without code",
});
new FetchError("message", "type");
}