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

feat: add hook before prepare:types #2505

Draft
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

Barbapapazes
Copy link
Member

@Barbapapazes Barbapapazes commented Jun 10, 2024

πŸ”— Linked issue

related to #1710

❓ 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

Hello πŸ‘‹,

This PR allows modules developers to add references or tweak the tsconfig file before saving it.

I also refactor how references are build to easily add a new one (just a path).

This hook is similar to the one in Nuxt.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@Barbapapazes Barbapapazes mentioned this pull request Jun 10, 2024
8 tasks
@pi0 pi0 marked this pull request as draft June 11, 2024 12:13
@pi0
Copy link
Member

pi0 commented Jun 11, 2024

types:extend hook was added via #1715 to allow extending types via a hook (#1710)

Allow extending more items like declarations is good idea, thinking to do few structure changes to allow it (we don't need a new hook, i hope)

@Barbapapazes
Copy link
Member Author

Barbapapazes commented Jun 11, 2024

types:extend hook was added via #1715 to allow extending types via a hook (#1710)

Allow extending more items like declarations is good idea, thinking to do few structure changes to allow it (we don't need a new hook, i hope)

Still in my module, explained here #2506 (comment)

Yes! My TypeScript knowledge led me updating what I thought was the main file .nuxt/nuxt.d.ts to augment Nuxt and Vue types. After, I tried to do the same to Nitro but it was not possible so I propose this change, similar to the current behavior of Nuxt.

But, after deep diving into the tsconfig file and the files created by Nuxt, it seems that Nuxt automatically add a path to the current module and because it's a directory, it's possible to add .d.ts file which is way more elegant than a template file since it's not dynamic.

The Nuxt module author guide, https://nuxt.com/docs/guide/going-further/modules#adding-type-declarations, is very misleading about the usage of template so typescript and I will open an issue.

While writing these lines, I haven't check if Nitro add a similar line, a reference to the module to allow .d.ts, or if it's come from Nuxt but it could help to have the same (well documented) in Nitro. But there is still the question for dynamic .d.ts file, like the one Nitro generate for the app.config or the routes definitions.

@pi0 pi0 changed the base branch from main to v2 June 13, 2024 14:04
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.

2 participants