Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24
cache: "pnpm"

- name: Install dependencies
Expand Down
19 changes: 18 additions & 1 deletion docs/src/content/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Contributing to OpenAPI React Query Codegen.

## Prerequisites

- Node.js v20.16.0 or later
- Node.js v24 or later
- pnpm v9

## Install dependencies
Expand Down Expand Up @@ -45,3 +45,20 @@ npm run build && pnpm --filter @7nohe/react-app generate:api && pnpm --filter @7
```bash
pnpm --filter docs dev
```

## Type patches for dependencies

This project compiles with `skipLibCheck: false`, so type errors inside dependency declaration files fail the build. Two mechanisms keep it green:

- `patches/` contains [pnpm patches](https://pnpm.io/cli/patch) that insert `// @ts-ignore` comments over known typing bugs in the bundled declaration files of `@hey-api/openapi-ts` and `@hey-api/shared`. No implementation code is modified.
- `src/vendor-typestubs.d.ts` stubs modules referenced by `@hey-api/openapi-ts` type declarations but not installed here (framework-specific client plugins such as `ky`, `ofetch`, `nuxt/app`, `@angular/*`).

When upgrading `@hey-api/openapi-ts`, recreate the patches against the new version:

```bash
pnpm patch @hey-api/openapi-ts@<new-version>
# edit the printed directory, then
pnpm patch-commit <printed-directory>
```

Run `pnpm build` afterwards — any remaining declaration errors point to patches or stubs that need updating, and patches that no longer apply can be removed.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"license": "MIT",
"author": "Daiki Urata (@7nohe)",
"dependencies": {
"@hey-api/openapi-ts": "0.92.3",
"@hey-api/openapi-ts": "0.99.0",
"cross-spawn": "^7.0.3"
},
"devDependencies": {
Expand All @@ -59,23 +59,24 @@
"commander": "^12.0.0",
"lefthook": "^1.6.10",
"rimraf": "^5.0.5",
"ts-morph": "^27.0.2",
"typescript": "^5.9.3",
"ts-morph": "^28.0.0",
"typescript": "^6.0.3",
"vitest": "^1.5.0"
},
"peerDependencies": {
"commander": "12.x",
"ts-morph": "27.x",
"typescript": "5.x"
"ts-morph": "28.x",
"typescript": "5.x || 6.x"
},
"packageManager": "pnpm@9.6.0",
"engines": {
"node": ">=20.19.0",
"node": ">=22.18.0",
"pnpm": ">=9"
},
"pnpm": {
"patchedDependencies": {
"@hey-api/openapi-ts@0.92.3": "patches/@hey-api__openapi-ts@0.92.3.patch"
"@hey-api/openapi-ts@0.99.0": "patches/@hey-api__openapi-ts@0.99.0.patch",
"@hey-api/shared@0.5.0": "patches/@hey-api__shared@0.5.0.patch"
}
}
}
12 changes: 0 additions & 12 deletions patches/@hey-api__openapi-ts@0.92.3.patch

This file was deleted.

20 changes: 20 additions & 0 deletions patches/@hey-api__openapi-ts@0.99.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/dist/index.d.mts b/dist/index.d.mts
index f2ca29144731f9320cea459d0e290352e2701e92..4255212e3846fee11fa9dd77a782d5ce1a2e00c9 100644
--- a/dist/index.d.mts
+++ b/dist/index.d.mts
@@ -1475,6 +1475,7 @@ declare class ImplFuncTsDsl<M extends FuncMode = 'arrow'> extends Mixed$31 {
decl(): FuncTsDsl<'decl'>;
/** Switches the function to a function expression form. */
expr(): FuncTsDsl<'expr'>;
+ // @ts-ignore TS2416 - bundled declaration has incorrect base type TsDsl<ArrowFunction>; conditional return is valid at source level
toAst(): M extends 'decl' ? ts.FunctionDeclaration : M extends 'expr' ? ts.FunctionExpression : ts.ArrowFunction;
$validate(): asserts this;
private missingRequiredCalls;
@@ -1848,6 +1849,7 @@ declare class ImplForTsDsl<M extends ForMode = 'for'> extends Mixed$16 {
of(iterable?: ForIterable): ForTsDsl<'of'>;
/** Sets the update expression (e.g., `i++`). */
update(update: ForIterable): this;
+ // @ts-ignore TS2416 - bundled declaration has incorrect base type TsDsl<ForStatement>; conditional return is valid at source level
toAst(): M extends 'for' ? ts.ForStatement : M extends 'of' ? ts.ForOfStatement : ts.ForInStatement;
$validate(): asserts this is this & {
_iterableOrUpdate: ForIterable;
Comment on lines +1 to +20

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この変更の意味を教えてください

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このリポジトリは skipLibCheck: false でビルドしているため、依存パッケージの型定義ファイル内のエラーもビルドエラーになります。

@hey-api/openapi-ts がバンドルする dist/index.d.mts では、ImplForTsDsl.toAst() が conditional return type(M に応じて ForStatement | ForOfStatement | ForInStatement)を持つ一方、継承チェーンの基底型 TsDsl<ForStatement>toAst(): ForStatement を宣言しており、TS2416(プロパティの型非互換)になります。ソースコード上は有効なオーバーライドですが、rollup で単一の宣言ファイルに束ねられた際に矛盾として表面化する upstream の型バグです。

0.92.3 の patch で対応していた ImplFuncTsDsl.toAst()(このファイルの1つ目のハンク)と同種のエラーが、0.99.0 ではこの ImplForTsDsl.toAst() にも新たに発生したため、@ts-ignore を追加しています。upstream で修正されれば patch ごと削除できます。

12 changes: 12 additions & 0 deletions patches/@hey-api__shared@0.5.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/dist/index.d.mts b/dist/index.d.mts
index d4f7acfd6f4b0a65b9de871e7bc88a6151c8a520..1fdc18bb747a9dfc56b74e3e69e1e9ce3275ca85 100644
--- a/dist/index.d.mts
+++ b/dist/index.d.mts
@@ -3190,6 +3190,7 @@ declare function definePluginConfig<T extends Plugin.Types>(pluginConfig: Plugin
plugin: PluginInstance<T>;
}) => void;
imports?: ((plugin: PluginInstance<T>) => T["imports"]) | undefined;
+ // @ts-ignore TS2749 - bundled declaration references value 'log' as a type; upstream typing bug
symbolMeta?: (symbol: Omit<log, "name">) => log;
tags?: ReadonlyArray<PluginTag>;
};
Comment on lines +1 to +12

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この変更差分を教えてください

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hey-api/shared@0.5.0@hey-api/openapi-ts 0.99.0 の依存)の dist/index.d.mts

symbolMeta?: (symbol: Omit<log, "name">) => log;

という宣言があり、ここで参照されている log は同ファイル内で 値(ロガー関数) として宣言されているものです。値を型の位置で使っているため TS2749(log refers to a value, but is being used as a type)になります。本来は Symbol のメタ情報型を参照すべき upstream の typing バグです。

skipLibCheck: false を維持するため、この1行の直前に @ts-ignore コメントを挿入するだけの patch です(実装コードには一切手を入れていません)。0.92.3 では @hey-api/shared への patch は不要でしたが、0.5.0 で新規に発生したため追加しました。

Loading
Loading