Skip to content

Commit 8880ccd

Browse files
committed
Update swr-openapi dependencies
1 parent 626f490 commit 8880ccd

File tree

5 files changed

+22
-47
lines changed

5 files changed

+22
-47
lines changed

.changeset/gentle-snails-sort.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"swr-openapi": minor
3+
---
4+
5+
Update dependencies

packages/swr-openapi/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"version": "pnpm run build"
5757
},
5858
"peerDependencies": {
59-
"openapi-fetch": "0.12",
60-
"openapi-typescript": "7",
59+
"openapi-fetch": "workspace:0.x",
60+
"openapi-typescript": "workspace:7.x",
6161
"react": "18 || 19",
6262
"swr": "2",
6363
"typescript": "^5.x"
@@ -68,7 +68,7 @@
6868
}
6969
},
7070
"dependencies": {
71-
"openapi-typescript-helpers": "0.0.13",
71+
"openapi-typescript-helpers": "workspace:0.x",
7272
"type-fest": "4.26.1"
7373
},
7474
"devDependencies": {
@@ -79,8 +79,8 @@
7979
"husky": "9.1.5",
8080
"lint-staged": "15.2.10",
8181
"lodash": "4.17.21",
82-
"openapi-fetch": "0.12.0",
83-
"openapi-typescript": "7.4.0",
82+
"openapi-fetch": "workspace:0.x",
83+
"openapi-typescript": "workspace:7.x",
8484
"react": "18.3.1",
8585
"swr": "2.2.5",
8686
"typescript": "5.5.4",

packages/swr-openapi/src/__test__/types.test-d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Pet = components["schemas"]["Pet"];
2222
type PetInvalid = ErrorResponseJSON<paths["/pet/{petId}"]["get"]>;
2323
type PetStatusInvalid = ErrorResponseJSON<paths["/pet/findByStatus"]["get"]>;
2424
expectTypeOf<Pet>().toMatchTypeOf<{ name: string }>();
25-
expectTypeOf<PetInvalid>().toMatchTypeOf<{ message: string }>();
25+
expectTypeOf<PetInvalid>().toMatchTypeOf<{ message: string } | undefined>();
2626
expectTypeOf<PetStatusInvalid>().toMatchTypeOf<{ message: string }>();
2727

2828
// Set up hooks
@@ -383,7 +383,7 @@ describe("TypesForRequest", () => {
383383
it("returns correct error", () => {
384384
expectTypeOf<GetPet["Error"]>().toEqualTypeOf<PetInvalid>();
385385
expectTypeOf<FindPetsByStatus["Error"]>().toEqualTypeOf<PetStatusInvalid>();
386-
expectTypeOf<FindPetsByTags["Error"]>().toEqualTypeOf<never>();
386+
expectTypeOf<FindPetsByTags["Error"]>().toEqualTypeOf<undefined>();
387387
});
388388

389389
it("returns correct path params", () => {
@@ -430,7 +430,7 @@ describe("TypesForRequest", () => {
430430
it("returns correct SWR config", () => {
431431
expectTypeOf<GetPet["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet, PetInvalid>>();
432432
expectTypeOf<FindPetsByStatus["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet[], PetStatusInvalid>>();
433-
expectTypeOf<FindPetsByTags["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet[], never>>();
433+
expectTypeOf<FindPetsByTags["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet[], undefined>>();
434434
});
435435

436436
it("returns correct SWR response", () => {
@@ -441,7 +441,7 @@ describe("TypesForRequest", () => {
441441
SWR.SWRResponse<Pet[], PetStatusInvalid, SWR.SWRConfiguration<Pet[], PetStatusInvalid>>
442442
>();
443443
expectTypeOf<FindPetsByTags["SWRResponse"]>().toEqualTypeOf<
444-
SWR.SWRResponse<Pet[], never, SWR.SWRConfiguration<Pet[], never>>
444+
SWR.SWRResponse<Pet[], undefined, SWR.SWRConfiguration<Pet[], undefined>>
445445
>();
446446
});
447447
});

packages/swr-openapi/src/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type TryKey<T, K extends PropertyKey> = T extends { [Key in K]?: unknown } ? T[K
1010
* Provides specific types used within a given request
1111
*/
1212
export type TypesForRequest<
13-
Paths extends {},
13+
Paths extends Record<string | number, any>,
1414
Method extends Extract<HttpMethod, keyof Paths[keyof Paths]>,
1515
Path extends PathsWithMethod<Paths, Method>,
1616
// ---
@@ -42,6 +42,6 @@ export type TypesForRequest<
4242
* Uses {@link TypesForRequest}
4343
*/
4444
export type TypesForGetRequest<
45-
Paths extends {},
45+
Paths extends Record<string | number, any>,
4646
Path extends PathsWithMethod<Paths, Extract<"get", keyof Paths[keyof Paths]>>,
4747
> = TypesForRequest<Paths, Extract<"get", keyof Paths[keyof Paths]>, Path>;

pnpm-lock.yaml

+6-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)