Skip to content

Commit 6fe2c85

Browse files
authored
Chore: clean up some internal type errors (#1559)
1 parent 9158b81 commit 6fe2c85

File tree

16 files changed

+358
-387
lines changed

16 files changed

+358
-387
lines changed

.changeset/olive-dots-sing.md

-5
This file was deleted.

.changeset/selfish-olives-kiss.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"openapi-typescript-helpers": patch
3+
---
4+
5+
Simplify build

packages/openapi-fetch/examples/nextjs/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"allowJs": true,
5+
"baseUrl": ".",
56
"esModuleInterop": true,
67
"incremental": true,
78
"isolatedModules": true,

packages/openapi-fetch/examples/react-query/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
"dev": "vite dev"
77
},
88
"dependencies": {
9-
"@tanstack/react-query": "^5.13.4",
9+
"@tanstack/react-query": "^5.22.2",
1010
"openapi-fetch": "workspace:^",
1111
"openapi-typescript": "workspace:^",
1212
"react": "^18.2.0",
1313
"react-dom": "^18.2.0"
1414
},
1515
"devDependencies": {
16-
"@vitejs/plugin-react-swc": "^3.5.0",
16+
"@types/react": "18.2.20",
17+
"@types/react-dom": "18.2.7",
18+
"@vitejs/plugin-react-swc": "^3.6.0",
1719
"typescript": "^5.3.3",
18-
"vite": "^5.0.12"
20+
"vite": "^5.1.4"
1921
}
2022
}

packages/openapi-fetch/examples/react-query/src/hooks/queries.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export function getFact({
2727
// add any other hook dependencies here
2828
],
2929
queryFn: async ({ signal }) => {
30-
const { data, error } = await client.GET(GET_FACT, {
30+
const { data } = await client.GET(GET_FACT, {
3131
params,
3232
// body - isn’t used for GET, but needed for other request types
3333
signal, // allows React Query to cancel request
3434
});
35-
if (data) return data;
36-
throw new Error(error); // React Query expects errors to be thrown to show a message
35+
return data;
36+
// Note: Error throwing handled automatically via middleware
3737
},
3838
});
3939
}

packages/openapi-fetch/examples/react-query/src/index.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ function Fact() {
1414
<div>
1515
{fact.isLoading && <div>Loading...</div>}
1616
{fact.error ? (
17-
<div>There was an error: {fact.error}</div>
17+
<div>There was an error: {fact.error.message}</div>
1818
) : (
1919
<pre>
2020
<code>{JSON.stringify(fact.data, undefined, 2)}</code>
2121
</pre>
2222
)}
23-
<button type="button" onClick={() => fact.refetch()}>
23+
<button
24+
type="button"
25+
onClick={() => fact.refetch()}
26+
>
2427
Another fact!
2528
</button>
2629
</div>
@@ -45,6 +48,6 @@ function App() {
4548
);
4649
}
4750

48-
const domNode = document.getElementById("app");
51+
const domNode = document.getElementById("app")!;
4952
const root = createRoot(domNode);
5053
root.render(<App />);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"extends": "../../tsconfig.json"
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"jsx": "preserve",
6+
"module": "ESNext",
7+
"moduleResolution": "Node"
8+
},
9+
"include": ["src"]
310
}

packages/openapi-fetch/examples/sveltekit/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
"devDependencies": {
1515
"@sveltejs/adapter-auto": "^3.1.1",
1616
"@sveltejs/kit": "^2.5.0",
17-
"svelte": "^4.2.9",
18-
"svelte-check": "^3.6.3",
17+
"@sveltejs/vite-plugin-svelte": "^3.0.2",
18+
"svelte": "^4.2.11",
19+
"svelte-check": "^3.6.4",
1920
"tslib": "^2.6.2",
2021
"typescript": "^5.3.3",
21-
"vite": "^5.0.12"
22+
"vite": "^5.1.4"
2223
}
2324
}

packages/openapi-fetch/examples/sveltekit/svelte.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import adapter from "@sveltejs/adapter-auto";
2-
import { vitePreprocess } from "@sveltejs/kit/vite";
2+
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
33

44
/** @type {import('@sveltejs/kit').Config} */
55
const config = {
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"extends": "./.svelte-kit/tsconfig.json",
3-
"compilerOptions": {
4-
"allowJs": true,
5-
"checkJs": true,
6-
"esModuleInterop": true,
7-
"forceConsistentCasingInFileNames": true,
8-
"resolveJsonModule": true,
9-
"skipLibCheck": true,
10-
"sourceMap": true,
11-
"strict": true
12-
}
13-
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
14-
//
15-
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
16-
// from the referenced tsconfig.json - TypeScript does not merge them in
2+
"extends": "./.svelte-kit/tsconfig.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"checkJs": true,
6+
"lib": ["DOM"],
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"resolveJsonModule": true,
10+
"skipLibCheck": true,
11+
"sourceMap": true,
12+
"strict": true
13+
}
14+
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
15+
//
16+
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
17+
// from the referenced tsconfig.json - TypeScript does not merge them in
1718
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.d.cts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Stub file to allow importing from the root of the package.
3+
*/
4+
module.exports = null;

packages/openapi-typescript-helpers/package.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"exports": {
1414
".": {
1515
"import": {
16-
"types": "./dist/index.d.ts",
17-
"default": "./dist/index.js"
16+
"types": "./index.d.ts",
17+
"default": "./index.js"
1818
},
1919
"require": {
20-
"types": "./dist/cjs/index.d.cts",
21-
"default": "./dist/cjs/index.cjs"
20+
"types": "./index.d.cts",
21+
"default": "./index.cjs"
2222
}
2323
},
2424
"./*": "./*"
@@ -33,9 +33,7 @@
3333
"url": "https://github.com/drwpow/openapi-typescript/issues"
3434
},
3535
"scripts": {
36-
"build": "pnpm run build:clean && pnpm run build:js",
37-
"build:clean": "del dist",
38-
"build:js": "node ./scripts/build.js",
36+
"build": "cp index.d.ts index.d.cts",
3937
"lint": "pnpm run lint:js",
4038
"lint:js": "eslint \"*.{js,ts}\"",
4139
"lint:prettier": "prettier --check \"{src,test}/**/*\"",

packages/openapi-typescript-helpers/scripts/build.js

-32
This file was deleted.

packages/openapi-typescript/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171

7272
- [#1374](https://github.com/drwpow/openapi-typescript/pull/1374) [`7ac5174`](https://github.com/drwpow/openapi-typescript/commit/7ac5174a1f767c1103573543bb17622ac8d25fe4) Thanks [@ElForastero](https://github.com/ElForastero)! - Add support for x-enum-varnames and x-enum-descriptions
7373

74+
- [#1545](https://github.com/drwpow/openapi-typescript/pull/1545) [`9158b81`](https://github.com/drwpow/openapi-typescript/commit/9158b81e8fdd45491afde8e291a786d7b2abc154) Thanks [@jaredLunde](https://github.com/drwpow/openapi-typescript/commits?author=jaredLunde)! - Replace # characters in operation IDs with a slash
75+
7476
### Patch Changes
7577

7678
- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - Refactor internals to use TypeScript AST rather than string mashing

0 commit comments

Comments
 (0)