Support TypeScript 6.0.x and hey-api/openapi-ts 0.99.x#2
Conversation
…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
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
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
| 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; |
There was a problem hiding this comment.
このリポジトリは 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 ごと削除できます。
| 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>; | ||
| }; |
There was a problem hiding this comment.
@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 で新規に発生したため追加しました。
| declare module "ky" { | ||
| export interface Options { | ||
| [key: string]: any; | ||
| } | ||
| export type KyInstance = any; | ||
| const ky: any; | ||
| export default ky; | ||
| } | ||
|
|
There was a problem hiding this comment.
改善しました → 169cdf7
@hey-api/openapi-ts の型定義が ky から参照しているのは実質的に以下の3点だけなので、any を排除できました。
Pick<Options, "cache" | "credentials" | "retry" | "signal" | ... | "timeout">→ ky の実際のOptionsと同様にRequestInitを継承することで、これらのキーに DOM の正確な型(RequestCache/AbortSignalなど)が付くようにしましたky?: typeof ky→KyInstanceを最小限の callable interface として定義kyOptions?: Omit<Options, "method" | "prefixUrl">→ index signature は残しつつanyからunknownに変更(未参照の hooks / searchParams 等を受けるため)
skipLibCheck: false でのビルドが通ることを確認済みです。
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "noImplicitAny": true, | ||
| "downlevelIteration": true, |
There was a problem hiding this comment.
TypeScript 6.0 で downlevelIteration オプション自体が deprecated になり、tsconfig に残っていると TS5101 エラーでビルドが通らなくなります(7.0 で完全削除予定)。
また、このオプションは target が ES5 など古い場合に iteration 構文を変換するためのもので、本プロジェクトは target: ESNext のため downlevel 変換自体が発生せず、元々効果のない設定でした。ignoreDeprecations: "6.0" で警告を抑制して残す選択肢もありますが、無意味な設定を延命する理由がないため削除しています。
| "outDir": "dist", | ||
| "lib": ["ESNext", "DOM"], | ||
| "target": "ESNext", | ||
| "baseUrl": ".", |
There was a problem hiding this comment.
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
…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
Summary
Upgrades the core dependencies to the latest versions, on top of v2.1.0 (7nohe#192).
typescriptts-morph@hey-api/openapi-tsKey Changes
@hey-api/openapi-ts0.99.0@hey-api/sdkoptionoperationId: falsetooperations: { nesting: "id" }(identical behavior)downlevelIterationandbaseUrlfrom tsconfig — deprecated in TS 6.0 (TS5101) and both unused hereSyntaxKindvalue shifts between 5.9 and 6.0, so no AST-traversal changes neededtypescript: "5.x || 6.x",ts-morph: "28.x"skipLibCheck: falsesupport@hey-api/openapi-ts@0.99.0(TS2416 now in two places)@hey-api/shared@0.5.0(TS2749 — the valuelogreferenced as a type)kymodule stub tovendor-typestubs.d.ts(extendsRequestInit, noany)>=22.18.0(required by hey-api 0.96+)patches/+vendor-typestubs.d.ts)Test Plan
pnpm build(skipLibCheck: false) /pnpm biome check ./pnpm install --frozen-lockfilepnpm test— all 70 tests pass with zero snapshot changes (branch coverage 92.55%)test:generated(tsc) passes🤖 Generated with Claude Code
https://claude.ai/code/session_011dPzdeZL1kurBr7De3rYKN