Skip to content

docs: document curried pattern and named factory usage in defineTypedHrefWithNuqs#48

Draft
amotarao wants to merge 2 commits into
mainfrom
amon/simplify-nuqs-single-call
Draft

docs: document curried pattern and named factory usage in defineTypedHrefWithNuqs#48
amotarao wants to merge 2 commits into
mainfrom
amon/simplify-nuqs-single-call

Conversation

@amotarao
Copy link
Copy Markdown
Member

@amotarao amotarao commented Apr 22, 2026

Summary

defineTypedHrefWithNuqs()({...}) という二重呼び出し構文が気になるという指摘を受け、シングルコール <Routes, RouteParamsMap>(nuqsMap) に変更できないか調査した。

調査結果: TypeScript は明示的な型引数と残りの型引数の推論を同時に行えない(Partial Type Argument Inference が未実装 / microsoft/TypeScript#26242)。TypeScript 5.9 でも確認済み。

以下のアプローチをすべて試したが、NuqsMap が引数から推論されずデフォルト型が使われた:

  • デフォルト付き型パラメータ NuqsMap = NuqsParsersMap<Routes>
  • const 型パラメータ(TypeScript 5.0)
  • オーバーロード
  • object を制約にした intersection NuqsMap & NuqsParsersMap<Routes>
  • クロージャ経由

対応: カリー化の設計意図と、()({...}) を避けた Named Factory パターンを JSDoc に明記した。

// Recommended
const withNuqs = defineTypedHrefWithNuqs<Routes, RouteParamsMap>();
const { $href } = withNuqs({ "/search": { q: parseAsString } });

Summary by CodeRabbit

  • ドキュメント
    • nuqs 統合の使用例を、段階的に呼び出すパターン(ファクトリを取得してから構成を渡す)に合わせて分かりやすく更新しました。README の例とパターン説明を整理しています。
  • 雑務
    • パッケージ用の変更履歴エントリを追加し、次のパッチリリース向けにドキュメント変更を記録しました。

…HrefWithNuqs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e349312c-fe57-4739-a268-30a86395232b

📥 Commits

Reviewing files that changed from the base of the PR and between 27ce229 and 6571f69.

📒 Files selected for processing (2)
  • .changeset/teal-cups-swim.md
  • packages/next-typed-href/README.md
✅ Files skipped from review due to trivial changes (2)
  • .changeset/teal-cups-swim.md
  • packages/next-typed-href/README.md

ウォークスルー

defineTypedHrefWithNuqsのJSDocとREADME内サンプルを、カリー化された2段階の使用パターン(ジェネリックでファクトリーを取得→ファクトリーにnuqsマップを渡す)に更新しました。また、パッケージのChangesetを追加してパッチリリースを準備しました。実装や型、公開APIには変更ありません。

変更内容

Cohort / File(s) Summary
JSDoc / サンプル更新
packages/next-typed-href/src/nuqs.ts
defineTypedHrefWithNuqsのJSDoc内サンプルを、チェーン呼び出しからカリー化された2段階(factory取得→factory呼び出し)へ書き換え。ロジック/型は不変。
README サンプル更新
packages/next-typed-href/README.md
nuqs統合例を同様にリファクタ。defineTypedHrefWithNuqs<...>()const withNuqs = defineTypedHrefWithNuqs<...>()に置換し、その後withNuqs({ ... })$hrefを作成するパターンに統一。
リリース情報
.changeset/teal-cups-swim.md
パッチリリース用のChangesetを追加。JSDoc/サンプル変更をリリースノートに記載。

推定コードレビュー工数

🎯 1 (Trivial) | ⏱️ ~3分

関連する可能性のあるPR

レビュアーの提案

  • akameco
  • iromonek39

🐰✨ ドキュメント整えて、ステップは二つ、
ジェネリックで掴み、ファクトリーを呼ぶ。
使い方は軽やか、型はそのまま、
うさぎは跳ねて、リリースへ向かう。 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR タイトルは、変更内容の主要な目的(defineTypedHrefWithNuqsの curried パターンと named factory パターンのドキュメント化)を明確かつ簡潔に表現しており、実際の変更内容と完全に一致しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch amon/simplify-nuqs-single-call

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@amotarao amotarao marked this pull request as draft April 22, 2026 15:58
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