Skip to content

Commit bee536d

Browse files
authored
Support TypeScript5.9.x and hey-api/openapi-ts 0.92.x (#192)
1 parent 49a4fee commit bee536d

28 files changed

+1301
-481
lines changed

biome.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@
2424
"recommended": true
2525
}
2626
},
27+
"overrides": [
28+
{
29+
"include": ["src/vendor-typestubs.d.ts"],
30+
"linter": {
31+
"rules": {
32+
"suspicious": {
33+
"noExplicitAny": "off"
34+
}
35+
}
36+
}
37+
}
38+
],
2739
"formatter": {
2840
"enabled": true,
2941
"indentStyle": "space",

docs/src/content/docs/guides/cli-options.mdx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Initial page value to infinite query. The default value is `1`.
2727

2828
## Client Options
2929

30-
Due to the generated clients (Under the `openapi/requests` directory) being based on Hey API, you can pass some options to the Hey API client generator.
30+
The generated clients (under the `openapi/requests` directory) are produced by `@hey-api/openapi-ts` using its plugins system. The CLI options below are mapped to the corresponding plugin configurations.
3131

32-
You can find what options are passed to the Hey API client generator in the [generate](https://github.com/7nohe/openapi-react-query-codegen/blob/main/src/generate.mts) function.
32+
You can see the current configuration in the [generate](https://github.com/7nohe/openapi-react-query-codegen/blob/main/src/generate.mts) function.
3333

3434
### -c, --client \<value\>
3535

@@ -43,15 +43,15 @@ More details about the clients can be found in [Hey API Documentation](https://h
4343

4444
### --format \<value\>
4545

46-
Process output folder with formatter? The default value is `false`.
46+
Process the generated queries output folder (`openapi/queries`) with a formatter. The `openapi/requests` directory generated by `@hey-api/openapi-ts` is not affected by this option. The default value is `false`.
4747
The available options are:
4848

4949
- `biome`
5050
- `prettier`
5151

5252
### --lint \<value\>
5353

54-
Process output folder with linter? The default value is `false`.
54+
Process the generated queries output folder (`openapi/queries`) with a linter. The `openapi/requests` directory generated by `@hey-api/openapi-ts` is not affected by this option. The default value is `false`.
5555
The available options are:
5656

5757
- `biome`
@@ -71,19 +71,23 @@ The available options are:
7171

7272
### --useDateType
7373

74+
> **Deprecated:** This option is currently accepted but has no effect. It will be removed in a future version.
75+
7476
Use Date type instead of string for date. The default value is `false`.
7577

7678
### --debug
7779

80+
> **Deprecated:** This option is currently accepted but has no effect. It will be removed in a future version.
81+
7882
Run in debug mode? The default value is `false`.
7983

8084
### --noSchemas
8185

8286
Disable generating JSON schemas. The default value is `false`.
8387

84-
### --schemaTypes \<value\>
88+
### --schemaType \<value\>
8589

86-
Type of JSON schema. The default value is `json`.
90+
Type of JSON schema. Only applies when `--noSchemas` is not set. The default value is `json`.
8791
The available options are:
8892

8993
- `json`

docs/src/content/docs/guides/introduction.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ openapi/
7777
│ ├── queries.ts
7878
│ └── suspense.ts
7979
└── requests
80+
├── client/
81+
├── core/
82+
├── client.gen.ts
8083
├── index.ts
81-
├── schemas.gen.ts
84+
├── sdk.gen.ts
8285
├── services.gen.ts
8386
└── types.gen.ts
8487
```
@@ -107,6 +110,7 @@ import React from "react";
107110
import ReactDOM from "react-dom/client";
108111
import App from "./App";
109112
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
113+
// services.gen.ts is a backward-compatibility shim that re-exports from client.gen and sdk.gen
110114
import { client } from "../openapi/requests/services.gen";
111115

112116
client.setConfig({
@@ -180,6 +184,13 @@ export default App;
180184
- suspenses.ts Generated suspense hooks
181185
- prefetch.ts Generated prefetch functions
182186
- requests Output code generated by `@hey-api/openapi-ts`
187+
- client/ Hey API client implementation (internal)
188+
- core/ Hey API core utilities (internal)
189+
- client.gen.ts Client instance and configuration
190+
- sdk.gen.ts SDK functions (primary service functions)
191+
- services.gen.ts Backward-compatibility shim (re-exports from client.gen and sdk.gen)
192+
- types.gen.ts Generated TypeScript types
193+
- index.ts Barrel file
183194

184195
</FileTree>
185196

docs/src/content/docs/guides/usage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function App() {
2323
export default App;
2424
```
2525

26-
Optionally, you can also use the pure ts client in `openapi/requests/services.gen.ts` to customize your query.
26+
Optionally, you can also use the pure TypeScript client to customize your query. The SDK functions are defined in `openapi/requests/sdk.gen.ts` and are also available via the backward-compatible `openapi/requests/services.gen.ts` shim.
2727

2828
```tsx
2929
import { useQuery } from "@tanstack/react-query";

examples/nextjs-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test:generated": "tsc -p ./tsconfig.json --noEmit"
1414
},
1515
"dependencies": {
16+
"@hey-api/client-fetch": "^0.6.0",
1617
"@tanstack/react-query": "^5.59.13",
1718
"@tanstack/react-query-devtools": "^5.32.1",
1819
"next": "^14.2.3",

examples/nextjs-app/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"target": "es2017",
34
"lib": ["dom", "dom.iterable", "esnext"],
45
"allowJs": true,
56
"skipLibCheck": true,

examples/react-app/src/App.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import "./App.css";
22
import { useState } from "react";
33

4-
import { createClient } from "@hey-api/client-fetch";
54
import {
65
UseFindPetsKeyFn,
76
useAddPet,
@@ -13,8 +12,6 @@ import { SuspenseParent } from "./components/SuspenseParent";
1312
import { queryClient } from "./queryClient";
1413

1514
function App() {
16-
createClient({ baseUrl: "http://localhost:4010" });
17-
1815
const [tags, _setTags] = useState<string[]>([]);
1916
const [limit, _setLimit] = useState<number>(10);
2017

examples/tanstack-router-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"vite": "^5.4.4"
2525
},
2626
"dependencies": {
27+
"@hey-api/client-fetch": "^0.6.0",
2728
"@tanstack/react-query": "^5.59.13",
2829
"@tanstack/react-query-devtools": "^5.32.1",
2930
"@tanstack/react-router": "^1.58.7",

package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,35 @@
4747
"license": "MIT",
4848
"author": "Daiki Urata (@7nohe)",
4949
"dependencies": {
50-
"@hey-api/client-fetch": "0.4.0",
51-
"@hey-api/openapi-ts": "0.53.8",
50+
"@hey-api/openapi-ts": "0.92.3",
5251
"cross-spawn": "^7.0.3"
5352
},
5453
"devDependencies": {
5554
"@biomejs/biome": "^1.9.3",
5655
"@types/cross-spawn": "^6.0.6",
5756
"@types/node": "^22.7.4",
57+
"@types/semver": "^7.7.1",
5858
"@vitest/coverage-v8": "^1.5.0",
5959
"commander": "^12.0.0",
6060
"lefthook": "^1.6.10",
6161
"rimraf": "^5.0.5",
62-
"ts-morph": "^23.0.0",
63-
"typescript": "^5.5.4",
62+
"ts-morph": "^27.0.2",
63+
"typescript": "^5.9.3",
6464
"vitest": "^1.5.0"
6565
},
6666
"peerDependencies": {
6767
"commander": "12.x",
68-
"ts-morph": "23.x",
68+
"ts-morph": "27.x",
6969
"typescript": "5.x"
7070
},
7171
"packageManager": "pnpm@9.6.0",
7272
"engines": {
73-
"node": ">=14",
73+
"node": ">=20.19.0",
7474
"pnpm": ">=9"
75+
},
76+
"pnpm": {
77+
"patchedDependencies": {
78+
"@hey-api/openapi-ts@0.92.3": "patches/@hey-api__openapi-ts@0.92.3.patch"
79+
}
7580
}
7681
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/dist/index.d.mts b/dist/index.d.mts
2+
index fd805770f0aff4a9f6c57560554908764ed5bdce..af40ec3b83741774a9e0ad82caf0acd3c97a3b55 100644
3+
--- a/dist/index.d.mts
4+
+++ b/dist/index.d.mts
5+
@@ -1354,6 +1354,7 @@ declare class ImplFuncTsDsl<M extends FuncMode = 'arrow'> extends Mixed$27 {
6+
decl(): FuncTsDsl<'decl'>;
7+
/** Switches the function to a function expression form. */
8+
expr(): FuncTsDsl<'expr'>;
9+
+ // @ts-ignore TS2416 - bundled declaration has incorrect base type TsDsl<ArrowFunction>; conditional return is valid at source level
10+
toAst(): M extends 'decl' ? ts.FunctionDeclaration : M extends 'expr' ? ts.FunctionExpression : ts.ArrowFunction;
11+
$validate(): asserts this;
12+
private missingRequiredCalls;

0 commit comments

Comments
 (0)