Skip to content

fix(types): prevent registry entry types from collapsing to never#701

Merged
harlan-zw merged 1 commit intomainfrom
fix/registry-entry-any-type-collapse
Apr 11, 2026
Merged

fix(types): prevent registry entry types from collapsing to never#701
harlan-zw merged 1 commit intomainfrom
fix/registry-entry-any-type-collapse

Conversation

@harlan-zw
Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Resolves #700

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

RegistryConfigInput<T> uses [T] extends [true] to detect scripts with no options. However, [any] extends [true] also evaluates to true in TypeScript, which causes all script-specific properties to become never.

This triggers when Nuxt's $production/$development environment overrides apply a DeepPartial transformation that collapses the NuxtConfigScriptRegistry interface into a plain mapped type, losing interface property priority over the [key: string]: any index signature. All registry keys then resolve to any, and RegistryConfigInput<any> produces Record<string, never>.

Fixed by adding any detection (0 extends 1 & T) before the true check, so any resolves to Record<string, any> instead. Added a type test covering this case.

…d<string, never>

When Nuxt's $production/$development environment overrides apply DeepPartial,
the NuxtConfigScriptRegistry interface collapses to its index signature, resolving
all registry keys to `any`. RegistryConfigInput then matched `[any] extends [true]`
as true, producing Record<string, never> and making all script-specific properties
`never`.

Added `any` detection (0 extends 1 & T) before the true check so that `any`
resolves to Record<string, any> instead.

Resolves #700
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Error Error Apr 11, 2026 0:59am

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@701

commit: ea589ee

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 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: fd4b3b32-42e0-4474-9ab4-27e462954e6e

📥 Commits

Reviewing files that changed from the base of the PR and between 3fa134f and ea589ee.

📒 Files selected for processing (2)
  • packages/script/src/runtime/types.ts
  • test/types/types.test-d.ts

📝 Walkthrough

Walkthrough

The changes address a type inference issue in the registry configuration system by modifying the RegistryConfigInput<T> conditional type check. The conditional type now uses 0 extends 1 & T to detect non-literal and any types instead of the previous [T] extends [true] check. This prevents properties on arbitrary config objects from incorrectly resolving to never. Supporting type tests were added to validate the fix for NuxtConfigScriptRegistryEntry<any> behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: preventing registry entry types from collapsing to never, which is the primary technical fix in the PR.
Description check ✅ Passed The description explains the root cause (any detection issue), the triggering scenario (DeepPartial in environment overrides), the fix (0 extends 1 & T check), and links to the resolved issue.
Linked Issues check ✅ Passed The PR changes directly address issue #700 by modifying RegistryConfigInput to detect and handle any types correctly, and adds a type test confirming the fix prevents collapse to never.
Out of Scope Changes check ✅ Passed Both changes are in scope: the type fix in runtime/types.ts addresses the core issue, and the test in test/types/types.test-d.ts specifically validates the fix for issue #700.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/registry-entry-any-type-collapse

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 and usage tips.

@harlan-zw harlan-zw merged commit fdaf089 into main Apr 11, 2026
19 of 21 checks passed
@harlan-zw harlan-zw deleted the fix/registry-entry-any-type-collapse branch April 11, 2026 01:07
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.

Type-error inside scripts.registry: string is not assignable to never

1 participant