fix(types): prevent registry entry types from collapsing to never#701
fix(types): prevent registry entry types from collapsing to never#701
never#701Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe changes address a type inference issue in the registry configuration system by modifying the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🔗 Linked issue
Resolves #700
❓ Type of change
📚 Description
RegistryConfigInput<T>uses[T] extends [true]to detect scripts with no options. However,[any] extends [true]also evaluates totruein TypeScript, which causes all script-specific properties to becomenever.This triggers when Nuxt's
$production/$developmentenvironment overrides apply aDeepPartialtransformation that collapses theNuxtConfigScriptRegistryinterface into a plain mapped type, losing interface property priority over the[key: string]: anyindex signature. All registry keys then resolve toany, andRegistryConfigInput<any>producesRecord<string, never>.Fixed by adding
anydetection (0 extends 1 & T) before thetruecheck, soanyresolves toRecord<string, any>instead. Added a type test covering this case.