Skip to content

Commit

Permalink
refactor: improve PathParams type
Browse files Browse the repository at this point in the history
  • Loading branch information
kotarella1110 committed Apr 27, 2022
1 parent c2cd118 commit 7656a21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/rest.ts
Expand Up @@ -12,7 +12,7 @@ function createRestHandler<Method extends RESTMethods | RegExp>(
) {
return <
RequestBodyType extends DefaultBodyType = DefaultBodyType,
Params extends PathParams<Params> = PathParams,
Params extends PathParams<keyof Params> = PathParams,
ResponseBody extends DefaultBodyType = DefaultBodyType,
>(
path: Path,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/matching/matchRequestUrl.ts
Expand Up @@ -3,8 +3,8 @@ import { getCleanUrl } from '@mswjs/interceptors/lib/utils/getCleanUrl'
import { normalizePath } from './normalizePath'

export type Path = string | RegExp
export type PathParams<T = Record<string, string | ReadonlyArray<string>>> = {
[K in keyof T]?: string | ReadonlyArray<string>
export type PathParams<K extends keyof any = string> = {
[P in K]?: string | ReadonlyArray<string>
}

export interface Match {
Expand Down

0 comments on commit 7656a21

Please sign in to comment.