-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
enhancementNew feature or requestNew feature or request
Description
🆒 Your use case
When I create a custom script, I would expect it works just like a built-in script. Support initialize the custom script in both nuxt.config or app.vue.
export default defineNuxtConfig({
modules: ['@nuxt/scripts'],
compatibilityDate: '2025-07-15',
hooks: {
'scripts:registry': function (registry) {
registry.push({
category: 'custom',
label: 'My Custom Analytics',
import: {
name: 'useScriptMyCustomScript',
from: resolve('./app/composables/useScriptMyCustomScript'),
},
});
},
},
scripts: {
registry: {
myCustomScript: {
id: 'fake-account-id',
},
},
},
});If the custom is initialized in nuxt.config, TS server will complain:
Object literal may only specify known properties, and 'myCustomScript' does not exist in type 'Partial<{ [x: `${string}-npm`]: any; crisp: any; clarity: any; cloudflareWebAnalytics: any; databuddyAnalytics: any; metaPixel: any; fathomAnalytics: any; plausibleAnalytics: any; googleAdsense: any; googleAnalytics: any; ... 15 more ...; umamiAnalytics: any; }>'.ts(2353)
Although the project can still be ran, and built successfully, and all scripts are configurated, and working properly, it would be nice to have no type error for custom script configuration at the least.
🆕 The solution you'd like
- no type error when entering configuration for custom script in
scripts.registryinnuxt.config. - nice if there are autocompletions for the configuration of custom scripts
🔍 Alternatives you've considered
No response
ℹ️ Additional info
This issue is part of this issue, but I think I should mention it separately for easy tracking, and I'm not sure whether this is a bug or an expected behaviour.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request