|
1 | 1 | import type { ModuleOptions } from '../../packages/script/src/module' |
2 | 2 | import type { CrispApi } from '../../packages/script/src/runtime/registry/crisp' |
3 | 3 | 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' |
11 | 5 | import { describe, expectTypeOf, it } from 'vitest' |
12 | 6 |
|
13 | 7 | describe('module options registry', () => { |
@@ -78,6 +72,17 @@ describe('module options registry', () => { |
78 | 72 | // Unknown keys fall through to the index signature (any), so custom scripts work |
79 | 73 | expectTypeOf<Registry['my-custom-script']>().toBeAny() |
80 | 74 | }) |
| 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 | + }) |
81 | 86 | }) |
82 | 87 |
|
83 | 88 | describe('registry api types', () => { |
|
0 commit comments