Skip to content

Commit ed8d658

Browse files
authored
Merge branch 'main' into feat/proxy-url-signing
2 parents de1ecb4 + fdaf089 commit ed8d658

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

packages/script/src/runtime/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export type BuiltInRegistryScriptKey
253253
*/
254254
export type RegistryScriptKey = Exclude<keyof ScriptRegistry, `${string}-npm`>
255255

256-
type RegistryConfigInput<T> = [T] extends [true] ? Record<string, never> : T
256+
type RegistryConfigInput<T> = 0 extends 1 & T ? Record<string, any> : [T] extends [true] ? Record<string, never> : T
257257

258258
export type NuxtConfigScriptRegistryEntry<T> = true | false | 'mock' | (RegistryConfigInput<T> & { trigger?: NuxtUseScriptOptionsSerializable['trigger'] | false, proxy?: boolean, bundle?: boolean, partytown?: boolean, privacy?: ProxyPrivacyInput })
259259

test/types/types.test-d.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import type { ModuleOptions } from '../../packages/script/src/module'
22
import type { CrispApi } from '../../packages/script/src/runtime/registry/crisp'
33
import type { DefaultEventName } from '../../packages/script/src/runtime/registry/google-analytics'
4-
import type {
5-
NuxtConfigScriptRegistry,
6-
NuxtUseScriptOptions,
7-
RegistryScriptInput,
8-
ScriptRegistry,
9-
UseScriptContext,
10-
} from '../../packages/script/src/runtime/types'
4+
import type { NuxtConfigScriptRegistry, NuxtConfigScriptRegistryEntry, NuxtUseScriptOptions, RegistryScriptInput, ScriptRegistry, UseScriptContext } from '../../packages/script/src/runtime/types'
115
import { describe, expectTypeOf, it } from 'vitest'
126

137
describe('module options registry', () => {
@@ -78,6 +72,17 @@ describe('module options registry', () => {
7872
// Unknown keys fall through to the index signature (any), so custom scripts work
7973
expectTypeOf<Registry['my-custom-script']>().toBeAny()
8074
})
75+
76+
// Issue #700: NuxtConfigScriptRegistryEntry<any> must not collapse to Record<string, never>
77+
// This happens when Nuxt's $production/$development wraps the config in DeepPartial,
78+
// collapsing the interface's index signature priority and resolving all keys to `any`.
79+
it('NuxtConfigScriptRegistryEntry<any> allows arbitrary properties', () => {
80+
type Entry = Exclude<NuxtConfigScriptRegistryEntry<any>, boolean | 'mock'>
81+
// Must not be never (would mean Record<string, never> killed the intersection)
82+
expectTypeOf<Entry>().not.toBeNever()
83+
// Arbitrary properties must be assignable, not `never`
84+
expectTypeOf<{ matomoUrl: string, siteId: number }>().toMatchTypeOf<Entry>()
85+
})
8186
})
8287

8388
describe('registry api types', () => {

0 commit comments

Comments
 (0)