Skip to content

Support TypeScript 6.0.x and hey-api/openapi-ts 0.99.x#2

Open
TakehiroTada wants to merge 6 commits into
mainfrom
feature/support-hey-api-0.99.x-ts-6.0
Open

Support TypeScript 6.0.x and hey-api/openapi-ts 0.99.x#2
TakehiroTada wants to merge 6 commits into
mainfrom
feature/support-hey-api-0.99.x-ts-6.0

Conversation

@TakehiroTada

@TakehiroTada TakehiroTada commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Upgrades the core dependencies to the latest versions, on top of v2.1.0 (7nohe#192).

Package Before After
typescript 5.9.3 6.0.3
ts-morph 27.x 28.x
@hey-api/openapi-ts 0.92.3 0.99.0

Key Changes

  • @hey-api/openapi-ts 0.99.0
    • Migrated the deprecated @hey-api/sdk option operationId: false to operations: { nesting: "id" } (identical behavior)
  • TypeScript 6.0 / ts-morph 28
    • Removed downlevelIteration and baseUrl from tsconfig — deprecated in TS 6.0 (TS5101) and both unused here
    • No SyntaxKind value shifts between 5.9 and 6.0, so no AST-traversal changes needed
    • peerDependencies: typescript: "5.x || 6.x", ts-morph: "28.x"
  • skipLibCheck: false support
    • Recreated the pnpm patch for @hey-api/openapi-ts@0.99.0 (TS2416 now in two places)
    • Added a pnpm patch for @hey-api/shared@0.5.0 (TS2749 — the value log referenced as a type)
    • Added a typed ky module stub to vendor-typestubs.d.ts (extends RequestInit, no any)
  • Node.js
    • engines: >=22.18.0 (required by hey-api 0.96+)
    • Test workflow and contributing guide now use Node.js 24, aligning with the release workflow
  • Docs
    • Contributing guide: new section on the type-patch workflow (patches/ + vendor-typestubs.d.ts)

Test Plan

  • pnpm build (skipLibCheck: false) / pnpm biome check . / pnpm install --frozen-lockfile
  • pnpm test — all 70 tests pass with zero snapshot changes (branch coverage 92.55%)
  • Codegen re-run for all 5 example apps — zero output diff, test:generated (tsc) passes

🤖 Generated with Claude Code

https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN

TakehiroTada and others added 3 commits July 3, 2026 08:48
…morph to 28

- Recreate the pnpm patch for @hey-api/openapi-ts@0.99.0: the TS2416 on
  ImplFuncTsDsl.toAst() persists and a second one appeared on
  ImplForTsDsl.toAst()
- Add a pnpm patch for @hey-api/shared@0.5.0, which references the value
  'log' as a type (TS2749) — both patches keep skipLibCheck: false working
- Add a 'ky' module stub to vendor-typestubs.d.ts for the bundled ky client
  plugin type declarations
- Drop downlevelIteration and baseUrl from tsconfig.json (deprecated in
  TypeScript 6.0, both unused here)
- Allow typescript 5.x || 6.x and require ts-morph 28.x as peer dependencies

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN
….nesting

@hey-api/openapi-ts 0.99 deprecates the sdk plugin's boolean operationId
option. operationId: false maps internally to operations: { nesting: 'id' },
so pass the new option directly to silence the deprecation warning while
keeping --noOperationId behavior identical.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN
@hey-api/openapi-ts raised its minimum Node.js version to 22.18.0 in 0.96+,
so bump the CI matrix and the contributing guide accordingly (package.json
engines is updated in the dependency upgrade commit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 99.12% (🎯 95%) 2483 / 2505
🔵 Statements 99.12% (🎯 95%) 2483 / 2505
🔵 Functions 100% (🎯 95%) 48 / 48
🔵 Branches 92.55% (🎯 90%) 199 / 215
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/generate.mts 100% 100% 100% 100%
Generated in workflow #4 for commit 6f5af64 by the Vitest Coverage Report Action

Align the test matrix and the contributing guide with the release workflow,
which already runs on Node.js 24. package.json engines stay at >=22.18.0 —
the actual minimum required by @hey-api/openapi-ts 0.99.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN
Comment on lines +1 to +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;

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 ごと削除できます。

Comment on lines +1 to +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>;
};

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 で新規に発生したため追加しました。

Comment thread src/vendor-typestubs.d.ts
Comment on lines +51 to +59
declare module "ky" {
export interface Options {
[key: string]: any;
}
export type KyInstance = any;
const ky: any;
export default ky;
}

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.

このanyは改善できませんか

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.

改善しました → 169cdf7

@hey-api/openapi-ts の型定義が ky から参照しているのは実質的に以下の3点だけなので、any を排除できました。

  • Pick<Options, "cache" | "credentials" | "retry" | "signal" | ... | "timeout"> → ky の実際の Options と同様に RequestInit を継承することで、これらのキーに DOM の正確な型(RequestCache / AbortSignal など)が付くようにしました
  • ky?: typeof kyKyInstance を最小限の callable interface として定義
  • kyOptions?: Omit<Options, "method" | "prefixUrl"> → index signature は残しつつ any から unknown に変更(未参照の hooks / searchParams 等を受けるため)

skipLibCheck: false でのビルドが通ることを確認済みです。

Comment thread tsconfig.json
"strict": true,
"esModuleInterop": true,
"noImplicitAny": true,
"downlevelIteration": true,

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.

TypeScript 6.0 で downlevelIteration オプション自体が deprecated になり、tsconfig に残っていると TS5101 エラーでビルドが通らなくなります(7.0 で完全削除予定)。

また、このオプションは target が ES5 など古い場合に iteration 構文を変換するためのもので、本プロジェクトは target: ESNext のため downlevel 変換自体が発生せず、元々効果のない設定でした。ignoreDeprecations: "6.0" で警告を抑制して残す選択肢もありますが、無意味な設定を延命する理由がないため削除しています。

Comment thread tsconfig.json
"outDir": "dist",
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"baseUrl": ".",

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.

TypeScript 6.0 で baseUrl が deprecated になり、tsconfig に残っていると TS5101 エラーでビルドが通らなくなります(TS 6 以降は paths 側に prefix を書く方式へ移行する方針で、7.0 で完全削除予定です)。

baseUrl は non-relative import をルートディレクトリから解決するためのオプションですが、本プロジェクトは paths を使っておらず、baseUrl: "." に依存した bare import もないため、削除しても解決結果は変わりません(ビルド・全テストで確認済み)。

Extend RequestInit (which provides the members @hey-api/openapi-ts picks
from ky's Options) and model KyInstance as a minimal callable interface,
replacing the previous any-based stub. The unknown index signature keeps
unreferenced ky options open without weakening type checking.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN
@TakehiroTada TakehiroTada self-assigned this Jul 4, 2026
…ng guide

Contributors upgrading @hey-api/openapi-ts need to know why patches/ and
src/vendor-typestubs.d.ts exist and how to recreate the pnpm patches, now
that the 0.99.0 upgrade added a second patched package (@hey-api/shared).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN
@TakehiroTada TakehiroTada marked this pull request as ready for review July 4, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant