From 5bdd1417ab75346685d0cd7e09d2cd8da5eb871a Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 19 Jan 2026 13:32:55 +0000 Subject: [PATCH 1/3] fix: align templates with existing aguments --- src/templates.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/templates.ts b/src/templates.ts index f1b2cd40..5a34d898 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -25,11 +25,11 @@ export function registerTypeTemplates({ nuxt, config, newScripts }: TypeTemplate let augments = `// Generated by @nuxt/scripts declare module '#app' { interface NuxtApp { - $scripts: Record<${[...Object.keys(config.globals || {}), ...Object.keys(config.registry || {})].map(k => `'${k}'`).concat(['string']).join(' | ')}, import('#nuxt-scripts/types').UseScriptContext> - _scripts: Record> + $scripts: Record<${[...Object.keys(config.globals || {}), ...Object.keys(config.registry || {})].map(k => `'${k}'`).concat(['string']).join(' | ')}, (import('#nuxt-scripts').NuxtDevToolsScriptInstance)> + _scripts: Record } interface RuntimeNuxtHooks { - 'scripts:updated': (ctx: { scripts: Record> }) => void | Promise + 'scripts:updated': (ctx: { scripts: Record }) => void | Promise } } ` @@ -40,10 +40,10 @@ declare module '#nuxt-scripts/types' { type _NuxtScriptOptions = Omit interface ScriptRegistry { ${newScripts.map((i) => { - const key = i.import.name.replace('useScript', '') - const keyLcFirst = key.substring(0, 1).toLowerCase() + key.substring(1) - return ` ${keyLcFirst}?: import('${i.import.from}').${key}Input | [import('${i.import.from}').${key}Input, _NuxtScriptOptions]` -}).join('\n')} + const key = i.import.name.replace('useScript', '') + const keyLcFirst = key.substring(0, 1).toLowerCase() + key.substring(1) + return ` ${keyLcFirst}?: import('${i.import.from}').${key}Input | [import('${i.import.from}').${key}Input, _NuxtScriptOptions]` + }).join('\n')} } } ` From 30bc0b7e7e90ed47874fb7f88427f4e05ad20b74 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 19 Jan 2026 13:37:41 +0000 Subject: [PATCH 2/3] fix: remove unnecessary typecast --- src/runtime/composables/useScript.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/composables/useScript.ts b/src/runtime/composables/useScript.ts index c64e71ee..50f4c4ae 100644 --- a/src/runtime/composables/useScript.ts +++ b/src/runtime/composables/useScript.ts @@ -98,7 +98,7 @@ export function useScript = Record }) + nuxtApp.hooks.callHook('scripts:updated', { scripts: nuxtApp._scripts }) } if (!nuxtApp._scripts[instance.id]) { From ec82982d44ee35b999a72752357be698c36b20b5 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Tue, 20 Jan 2026 12:18:03 +1100 Subject: [PATCH 3/3] chore: types --- src/templates.ts | 6 +++--- types.d.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/templates.ts b/src/templates.ts index 4fecb955..30060b4f 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -25,11 +25,11 @@ export function registerTypeTemplates({ nuxt, config, newScripts }: TypeTemplate let augments = `// Generated by @nuxt/scripts declare module '#app' { interface NuxtApp { - $scripts: Record<${[...Object.keys(config.globals || {}), ...Object.keys(config.registry || {})].map(k => `'${k}'`).concat(['string']).join(' | ')}, (import('#nuxt-scripts').NuxtDevToolsScriptInstance)> - _scripts: Record + $scripts: Record<${[...Object.keys(config.globals || {}), ...Object.keys(config.registry || {})].map(k => `'${k}'`).concat(['string']).join(' | ')}, import('#nuxt-scripts/types').UseScriptContext | undefined> + _scripts: Record } interface RuntimeNuxtHooks { - 'scripts:updated': (ctx: { scripts: Record }) => void | Promise + 'scripts:updated': (ctx: { scripts: Record }) => void | Promise } } ` diff --git a/types.d.ts b/types.d.ts index a27cdd23..b1ce7fa9 100644 --- a/types.d.ts +++ b/types.d.ts @@ -2,11 +2,11 @@ declare module '#app' { interface NuxtApp { - _scripts: Record - $scripts: Record + _scripts: Record + $scripts: Record | undefined> } interface RuntimeNuxtHooks { - 'scripts:updated': (ctx: { scripts: Record }) => void | Promise + 'scripts:updated': (ctx: { scripts: Record }) => void | Promise } }