diff --git a/lib/msw-config.ts b/lib/msw-config.ts index abd4691..ada59c8 100644 --- a/lib/msw-config.ts +++ b/lib/msw-config.ts @@ -6,11 +6,7 @@ import { type SetupWorkerApi, } from 'msw'; import type { Server } from 'miragejs'; -import type { - HandlerOptions, - RouteHandler, - ServerConfig, -} from 'miragejs/server'; +import type { RouteHandler, ServerConfig } from 'miragejs/server'; import type { AnyFactories, AnyModels, AnyRegistry } from 'miragejs/-types'; type RawHandler = RouteHandler | {}; @@ -29,12 +25,23 @@ type HTTPVerb = | 'options' | 'head'; -type BaseHandler = ( - path: string, - // TODO: infer registry - handler?: RouteHandler, - options?: HandlerOptions -) => void; +/** e.g. "/movies/:id" */ +type Shorthand = string; + +type RouteArgs = + | [RouteOptions] + | [Record, ResponseCode] + | [Function, ResponseCode] + | [Shorthand, RouteOptions] + | [Shorthand, ResponseCode, RouteOptions]; + +type RouteArguments = [ + RawHandler | undefined, + ResponseCode | undefined, + RouteOptions, +]; + +type BaseHandler = (path: string, ...args: RouteArgs) => void; type MirageServer = { registerRouteHandler: ( @@ -94,22 +101,6 @@ function isOption(option: unknown): option is RouteOptions { return false; } -/** e.g. "/movies/:id" */ -type Shorthand = string; - -type RouteArgs = - | [RouteOptions] - | [Record, ResponseCode] - | [Function, ResponseCode] - | [Shorthand, RouteOptions] - | [Shorthand, ResponseCode, RouteOptions]; - -type RouteArguments = [ - RawHandler | undefined, - ResponseCode | undefined, - RouteOptions, -]; - /** * Extract arguments for a route. *