From 13e1fc64ca3a36f54765d588dc61d44cc92cd413 Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Fri, 2 Aug 2024 14:16:51 +0100 Subject: [PATCH] fix: correct types so that global optiosn can be passed in to route --- packages/core/src/CallHistory.js | 6 +++--- packages/core/src/Route.js | 6 +++--- packages/core/types/CallHistory.d.ts | 2 +- packages/core/types/Route.d.ts | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/core/src/CallHistory.js b/packages/core/src/CallHistory.js index 873d41592..7d4fbb69f 100644 --- a/packages/core/src/CallHistory.js +++ b/packages/core/src/CallHistory.js @@ -48,13 +48,13 @@ const isMatchedOrUnmatched = (filter) => class CallHistory { /** - * @param {FetchMockConfig} globalConfig + * @param {FetchMockConfig} config * @param {Router} router */ - constructor(globalConfig, router) { + constructor(config, router) { /** @type {CallLog[]} */ this.callLogs = []; - this.config = globalConfig; + this.config = config; this.router = router; } /** diff --git a/packages/core/src/Route.js b/packages/core/src/Route.js index e24106b9e..53001141e 100644 --- a/packages/core/src/Route.js +++ b/packages/core/src/Route.js @@ -11,7 +11,7 @@ import statusTextMap from './StatusTextMap.js'; /** @typedef {import('./FetchMock.js').FetchImplementations} FetchImplementations */ /** - * @typedef UserRouteConfig + * @typedef UserRouteSpecificConfig * @property {RouteName} [name] * @property {string} [method] * @property {{ [key: string]: string | number }} [headers] @@ -32,8 +32,8 @@ import statusTextMap from './StatusTextMap.js'; * @property {boolean} [isFallback] */ -/** @typedef {UserRouteConfig & FetchMockGlobalConfig} ExtendedUserRouteConfig */ -/** @typedef {ExtendedUserRouteConfig & FetchImplementations & InternalRouteConfig} RouteConfig */ +/** @typedef {UserRouteSpecificConfig & FetchMockGlobalConfig} UserRouteConfig */ +/** @typedef {UserRouteConfig & FetchImplementations & InternalRouteConfig} RouteConfig */ /** * @typedef RouteResponseConfig { diff --git a/packages/core/types/CallHistory.d.ts b/packages/core/types/CallHistory.d.ts index 902e04813..e3a7634e0 100644 --- a/packages/core/types/CallHistory.d.ts +++ b/packages/core/types/CallHistory.d.ts @@ -22,7 +22,7 @@ export type Matched = "matched"; export type Unmatched = "unmatched"; export type CallHistoryFilter = RouteName | Matched | Unmatched | boolean | RouteMatcher; declare class CallHistory { - constructor(globalConfig: FetchMockConfig, router: Router); + constructor(config: FetchMockConfig, router: Router); callLogs: CallLog[]; config: import("./FetchMock.js").FetchMockConfig; router: Router; diff --git a/packages/core/types/Route.d.ts b/packages/core/types/Route.d.ts index 6efdb646a..812ea10e8 100644 --- a/packages/core/types/Route.d.ts +++ b/packages/core/types/Route.d.ts @@ -6,7 +6,7 @@ export type RouteMatcherUrl = import("./Matchers.js").RouteMatcherUrl; export type MatcherDefinition = import("./Matchers.js").MatcherDefinition; export type FetchMockGlobalConfig = import("./FetchMock.js").FetchMockGlobalConfig; export type FetchImplementations = import("./FetchMock.js").FetchImplementations; -export type UserRouteConfig = { +export type UserRouteSpecificConfig = { name?: RouteName; method?: string; headers?: { @@ -30,8 +30,8 @@ export type InternalRouteConfig = { usesBody?: boolean; isFallback?: boolean; }; -export type ExtendedUserRouteConfig = UserRouteConfig & FetchMockGlobalConfig; -export type RouteConfig = ExtendedUserRouteConfig & FetchImplementations & InternalRouteConfig; +export type UserRouteConfig = UserRouteSpecificConfig & FetchMockGlobalConfig; +export type RouteConfig = UserRouteConfig & FetchImplementations & InternalRouteConfig; export type RouteResponseConfig = { body?: string | {}; status?: number;