Skip to content

Commit

Permalink
Merge pull request #768 from wheresrhys/rhys/correct-route-config-types
Browse files Browse the repository at this point in the history
fix: correct types so that global optiosn can be passed in to route
  • Loading branch information
wheresrhys authored Aug 2, 2024
2 parents 32e529a + 13e1fc6 commit 2768ea6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/CallHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/**
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/types/CallHistory.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/types/Route.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?: {
Expand All @@ -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;
Expand Down

0 comments on commit 2768ea6

Please sign in to comment.