Skip to content

Commit

Permalink
DEVTASKS-44: правки опечаток. Подготовка пакета к публикации
Browse files Browse the repository at this point in the history
  • Loading branch information
Denwa799 committed Jan 11, 2024
1 parent 4157471 commit cfa236c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions example/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface TestApi {
id2: string;
};
response: {
id2: "string";
id2: string;
data2: object;
};
};
Expand All @@ -38,7 +38,7 @@ export interface TestApi {
id3: string;
};
response: {
id3: "string";
id3: string;
data3: object;
};
};
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"name": "msw-types",
"name": "@web-bee-ru/msw-types",
"version": "0.2.0",
"description": "",
"private": false,
"keywords": ["msw"],
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"type": "commonjs",
"scripts": {
"start": "node ./dist/src/index.js",
Expand Down
8 changes: 7 additions & 1 deletion src/TypedHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ export class TypedHttp<T extends Scheme> {
* Обертка над обработчиком, чтобы прокинуть query в объект HttpRequest
*/
private prepareHandler<M extends Method, K extends Routes<T, M>>(handler: HandlerType<T, M, K>) {
return ({ request, params }: { request: StrictRequest<DefaultBodyType>; params: unknown }) => {
return ({
request,
params,
}: {
request: StrictRequest<DefaultBodyType>;
params: PathParams;
}) => {
const reqWithQuery = request as ReqType<T, M, K>;
const newParams = params as Params<T, M, K>;
const url = new URL(request.url);
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultBodyType, HttpResponse, StrictRequest } from "msw";
import { DefaultBodyType, HttpResponse, PathParams, StrictRequest } from "msw";
import { ConditionalPick } from "type-fest";

export type Method = "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "PATCH";
Expand Down Expand Up @@ -72,5 +72,5 @@ export type HandlerType<T extends Scheme, M extends Method, K extends Routes<T,
params,
}: {
request: ReqType<T, M, K>;
params: unknown;
params: PathParams;
}) => HttpResponse | Promise<HttpResponse>;

0 comments on commit cfa236c

Please sign in to comment.