Skip to content

fix(ai-grok): remove Record<string,unknown> index sig from GrokTextProviderOptions#835

Open
citizen204 wants to merge 1 commit into
TanStack:mainfrom
citizen204:fix-821-grok-provider-options-index-sig
Open

fix(ai-grok): remove Record<string,unknown> index sig from GrokTextProviderOptions#835
citizen204 wants to merge 1 commit into
TanStack:mainfrom
citizen204:fix-821-grok-provider-options-index-sig

Conversation

@citizen204

@citizen204 citizen204 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

grokSummarize('grok-4.3') and grokSummarize('grok-build-0.1') are not assignable to summarize()'s adapter parameter, producing a type error at every call site.

Fixes #821

Root cause

GrokTextProviderOptions extends both GrokBaseOptions and Record<string, unknown>. Under strictFunctionTypes, function parameters are checked contravariantly. The constraint on summarize<TAdapter extends SummarizeAdapter<string, object>> means the adapter's summarize method must accept SummarizationOptions<object>. Contravariance requires object to be assignable to GrokTextProviderOptions. But object is not assignable to Record<string, unknown> (index-signature types require a compatible index signature from the source), so the check fails.

OpenAI's provider options have no index signature and all-optional named fields, so they pass: object satisfies any all-optional interface.

Fix

Remove Record<string, unknown> from the extends clause of GrokTextProviderOptions. All fields are explicitly typed optional members — the index signature was not needed. After this change, object is assignable to GrokTextProviderOptions (all-optional, no index signature), fixing the contravariant check.

GrokBuildProviderOptions (Omit<GrokTextProviderOptions, 'reasoning'>) is not affected: the named fields are preserved correctly by Omit since there is no longer an index signature to collapse.

The TProviderOptions extends Record<string, unknown> constraint on GrokTextAdapter remains satisfied: a named-property interface with unknown-compatible values is structurally assignable to Record<string, unknown>.

Changes

  • packages/ai-grok/src/text/text-provider-options.ts: Remove Record<string, unknown> from GrokTextProviderOptions extends clause
  • .changeset/fix-grok-provider-options-index-sig.md: Patch changeset for @tanstack/ai-grok

Summary by CodeRabbit

  • Bug Fixes
    • Improved TypeScript type compatibility for Grok summarization adapters, eliminating strict type errors at summarize() call sites.
    • Updated Grok text provider options to rely only on explicitly defined fields, removing the overly broad option shape that caused mismatches under strict function typing.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c19df0e1-f496-4382-afe4-3973568ae469

📥 Commits

Reviewing files that changed from the base of the PR and between 26d183e and 7ba8441.

📒 Files selected for processing (2)
  • .changeset/fix-grok-provider-options-index-sig.md
  • packages/ai-grok/src/text/text-provider-options.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fix-grok-provider-options-index-sig.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ai-grok/src/text/text-provider-options.ts

📝 Walkthrough

Walkthrough

GrokTextProviderOptions no longer extends Record<string, unknown>, and the package changeset records the patch release for that type-only fix.

Changes

Grok options type fix

Layer / File(s) Summary
Options shape and changeset
packages/ai-grok/src/text/text-provider-options.ts, .changeset/fix-grok-provider-options-index-sig.md
GrokTextProviderOptions now extends only GrokBaseOptions, removing the catch-all index signature, and the changeset records the patch release for the fix.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

Poem

🐰 I nibble one type, so neat and small,
The index-sig falls, no more at all.
Grok hops through summarize() with ease,
And patch notes rustle in the breeze.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The type fix matches #821, but the required included-package call-site type coverage for grokSummarize/createGrokSummarize is missing. Add a type-level regression test in an included package that calls summarize() with grokSummarize('grok-4.3') and grokSummarize('grok-build-0.1').
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the Grok provider-options index-signature fix and matches the main change.
Description check ✅ Passed The description covers the summary, root cause, fix, and changed files, but omits the checklist and release-impact template sections.
Out of Scope Changes check ✅ Passed The changes stay focused on the Grok provider-options type shape and the related changeset, with no unrelated code edits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nx-cloud

nx-cloud Bot commented Jun 25, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 079c5a3

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ❌ Failed 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-25 09:48:31 UTC

@citizen204 citizen204 force-pushed the fix-821-grok-provider-options-index-sig branch from 079c5a3 to 7ba8441 Compare June 25, 2026 12:13
tombeckenham added a commit that referenced this pull request Jun 26, 2026
…ons (#820)

`test:pr`/`test:ci` excluded examples/** and testing/** from every target, so
`test:types` never checked the apps where the library is actually consumed —
call-site type regressions (e.g. a provider summarize adapter not assignable to
`summarize()`) slipped through CI. Because those surfaces were never type-checked,
they had also accumulated ~80 latent type errors.

CI wiring:
- test:pr / test:ci now run a second pass — `test:types` over examples/** and
  testing/** — after the existing packages-only run. Heavy targets (build/lib/...)
  stay excluded; only the cheap, high-value type check is added.
- Add `test:types:examples` convenience script and document the gate in CLAUDE.md.

Coverage:
- Add a `test:types` target to every example/testing project that lacked one
  (e2e, panel, react-native-chat, react-native-smoke). ts-angular-chat type-checks
  templates via `ngc`, resolved from an existing @angular/build peer (no new dep,
  no lockfile change).

Fixes (examples/testing drift from the current API; nothing under packages/**):
- ts-react-chat, ts-solid-chat, ts-code-mode-web: MediaPrompt, maxTokens→modelOptions,
  ContentPart[] narrowing, transport XOR.
- testing/e2e: drop poisoning `as never` model casts, fix adapter/tool typings,
  OpenRouter summarize httpClient header injection.
- testing/panel: AnyAdapter factory maps, AG-UI EventType migration, remove dead
  app.config.ts (Vinxi-era), rewrite createEventRecording to emit AG-UI StreamChunks.

Guard:
- packages/ai-grok/tests/summarize-callsite-type-safety.test.ts asserts the
  grokSummarize → summarize() contract in an included package (@ts-expect-error
  tracks the known #821 options-shape bug; flips positive when #835 lands).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

bug(ai-grok): grokSummarize is not assignable to summarize()'s adapter param for any current model

2 participants