Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): export interface for module builder type generation #738

Merged

Conversation

BobbieGoede
Copy link
Contributor

@BobbieGoede BobbieGoede commented Apr 16, 2024

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves #797

This moves the type augmentation to module.ts and exports the ModulePublicRuntimeConfig interface (as well as ModuleOptions) which are used by nuxt/module-builder to generate the correct types.

The original type augmentation is kept to for type inference in the source code (matches previous behaviour).

Without these changes the types will conflict with those of other modules (nuxt-modules/i18n#2915), I have tested these changes locally with the reproduction provided in the referenced issues and it seems to work.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@@ -245,3 +246,16 @@ export default defineNuxtModule<ModuleOptions>({
logger.success('`nuxt-auth` setup done')
}
}) satisfies NuxtModule<ModuleOptions>

// Used by nuxt/module-builder for `types.d.ts` generation
export type { ModuleOptions }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, you can export the whole file of types export * from './runtime/types' and this would generate the entire module

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaltoroc Thanks for your input, is there a strong reason why that is better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants