From a9adebaed439ed48ab3fbd2b85543fc594dd3948 Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Sat, 29 Sep 2018 13:16:54 +0900 Subject: [PATCH] fetch-mock: method option is optional Actually, it should be never but to keep compatibility, we decided to make this method option optional https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29264#discussion_r221364845 --- types/fetch-mock/fetch-mock-tests.ts | 1 + types/fetch-mock/index.d.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index b265e1c33f..1d5c5a51b3 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -62,6 +62,7 @@ fetchMock.patchOnce("http://test.com", 200); fetchMock.get("http://test.com", 200, {method: "GET"}); fetchMock.get("http://test.com", 200, {method: "GET", overwriteRoutes: true}); +fetchMock.get("http://test.com", 200, {overwriteRoutes: true}); fetchMock.post("http://test.com", 200, {method: "POST"}); fetchMock.put("http://test.com", 200, {method: "PUT"}); fetchMock.delete("http://test.com", 200, {method: "DELETE"}); diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index 891fb0ec7b..fdae338fce 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -6,6 +6,7 @@ // Chris Sinclair // Matt Tennison // Quentin Bouygues +// Fumiaki Matsushima // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -165,23 +166,23 @@ declare namespace fetchMock { } interface MockOptionsMethodGet extends MockOptions { - method: 'GET'; + method?: 'GET'; } interface MockOptionsMethodPost extends MockOptions { - method: 'POST'; + method?: 'POST'; } interface MockOptionsMethodPut extends MockOptions { - method: 'PUT'; + method?: 'PUT'; } interface MockOptionsMethodDelete extends MockOptions { - method: 'DELETE'; + method?: 'DELETE'; } interface MockOptionsMethodHead extends MockOptions { - method: 'HEAD'; + method?: 'HEAD'; } interface FetchMockStatic {