Skip to content

Commit

Permalink
refactor: avoid module declaration augmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 5, 2024
1 parent 05f085e commit b27d4ee
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,9 @@ export interface ModuleOptions {
}

export interface ModuleHooks {
/**
* Transform a script before it's registered.
*/
'scripts:registry': (registry: RegistryScripts) => void | Promise<void>
}

declare module '@nuxt/schema' {
interface NuxtHooks {
'scripts:registry': ModuleHooks['scripts:registry']
}
}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: '@nuxt/scripts',
Expand Down Expand Up @@ -140,6 +131,7 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.hooks.hook('modules:done', async () => {
const registryScripts = [...scripts]

// @ts-ignore nuxi prepare is broken to generate these types, possibly because of the runtime path

Check failure on line 134 in src/module.ts

View workflow job for this annotation

GitHub Actions / ci

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
await nuxt.hooks.callHook('scripts:registry', registryScripts)
const registryScriptsWithImport = registryScripts.filter(i => !!i.import?.name) as Required<RegistryScript>[]
addImports(registryScriptsWithImport.map((i) => {
Expand Down

0 comments on commit b27d4ee

Please sign in to comment.