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(schema): add more explicit types for config schema #21475
Conversation
@@ -48,7 +48,7 @@ export function viteNodePlugin (ctx: ViteBuildContext): VitePlugin { | |||
markInvalidates(server.moduleGraph.getModulesByFile(typeof plugin === 'string' ? plugin : plugin.src)) | |||
} | |||
for (const template of ctx.nuxt.options.build.templates) { | |||
markInvalidates(server.moduleGraph.getModulesByFile(template?.src)) | |||
markInvalidates(server.moduleGraph.getModulesByFile(template?.src as string)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because ctx.nuxt.options.build.templates
is no longer any
, TypeScript shows an error here, because the src
in NuxtTemplate can be undefined
.
I'm guilty of not trying out what happens (or even can it happen) if it is undefined
here, but I can investigate it further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. We do need to investigate - is it possible that the module would be added by template.dst
instead? π€ This may be the origin of a bug we're encountering elsewhere...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By quickly looking at the code, I think we expect to use template.getContents
when src
is not present (see), and we call that function at one place in the codebase, but we never set src
to anything if it is undefined
, so we can potentially call server.moduleGraph.getModulesByFile()
with undefined
.
Although yeah, I just glanced over the code, I'm gonna check this out more thoroughly tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great PR - many thanks for it β€οΈ
My pleasure @danielroe <3 |
defineNuxtConfig()
types
π Linked issue
Follow-up for #21363
β Type of change
π Description
This PR adds or updates the type annotation for the config properties wherever it was achievable (some webpack loaders for example don't have their own type annotations).
For other details, see my comments below.
π Checklist