diff --git a/types/node-fetch/index.d.ts b/types/node-fetch/index.d.ts index 311b1496f4..5756c6566c 100644 --- a/types/node-fetch/index.d.ts +++ b/types/node-fetch/index.d.ts @@ -9,6 +9,7 @@ // Brandon Wilson // Steve Faulkner // ExE Boss +// Alex Savin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -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; diff --git a/types/node-fetch/node-fetch-tests.ts b/types/node-fetch/node-fetch-tests.ts index 6f51f2a8b7..1d1ef8317d 100644 --- a/types/node-fetch/node-fetch-tests.ts +++ b/types/node-fetch/node-fetch-tests.ts @@ -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"); }