Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(nuxt): handle schema types for relative module paths - #7946

Merged
atinux merged 1 commit into
mainfrom
fix/relative-modules
Oct 3, 2022
Merged

fix(nuxt): handle schema types for relative module paths#7946
atinux merged 1 commit into
mainfrom
fix/relative-modules

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

In the case where a module is specified with a relative path, it is not properly typed in schema.d.ts. For example:

exportdefaultdefineNuxtConfig({modules: ['../src/module'],})

results in the following type:

declare module '@nuxt/schema'{interfaceNuxtConfig{["metaKey"]?: typeofimport("../src/module").defaultextendsNuxtModule<infer O> ? Partial<O> : Record<string,any>}}

But this relative import path either needs to be absolute or resolved relative to the generated schema.d.ts.

📝 Checklist

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

@danielroedanielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Oct 1, 2022
@danielroe
danielroe requested a review from pi0October 1, 2022 12:35
@danielroedanielroe self-assigned this Oct 1, 2022
@codesandbox

Copy link
Copy Markdown

CodeSandbox logoCodeSandbox logo Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify

netlifyBot commented Oct 1, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitafa2e34
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/633834149688400010d033cd

@atinuxatinux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@atinux
atinux merged commit 4823b17 into mainOct 3, 2022
@atinux
atinux deleted the fix/relative-modules branch October 3, 2022 13:32
@danielroedanielroe mentioned this pull request Oct 9, 2022
' interface NuxtConfig {',
...moduleInfo.filter(Boolean).map(meta =>
` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName.startsWith('.') ? './' + join(relativeRoot, meta.importName) : meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you tested if it also works with extends layers that have different relative root?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Could you explain more? If an extends layer adds a module with a relative path I suspect it wouldn't work at all, quite apart from this PR.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@danielroe@atinux@pi0