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

Nav types check error #710

Closed
3 tasks done
zRains opened this issue Jun 3, 2022 · 3 comments · Fixed by #711
Closed
3 tasks done

Nav types check error #710

zRains opened this issue Jun 3, 2022 · 3 comments · Fixed by #711
Labels
bug Something isn't working types Related to typings only

Comments

@zRains
Copy link
Contributor

zRains commented Jun 3, 2022

Describe the bug

Dropdown menu check:
QQ截图20220603231120

Reproduction

Set the demo config to nav:

export default {
  themeConfig: {
    nav: [
      { text: 'Guide', link: '/guide' },
      {
        text: 'Dropdown Menu',
        items: [
          {
            // Title for the section.
            text: 'Section A Title',
            items: [
              { text: 'Section A Item A', link: '...' },
              { text: 'Section B Item B', link: '...' }
            ]
          }
        ]
      },
      {
        text: 'Dropdown Menu',
        items: [
          {
            // You may also omit the title.
            items: [
              { text: 'Section A Item A', link: '...' },
              { text: 'Section B Item B', link: '...' }
            ]
          }
        ]
      }
    ]
  }
}

Expected behavior

No type check error.

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz

  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (102.0.1245.30)

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@zRains zRains added the bug: pending triage Maybe a bug, waiting for confirmation label Jun 3, 2022
@kecrily

This comment was marked as outdated.

@brc-dd
Copy link
Member

brc-dd commented Jun 3, 2022

Items cannot be nested within items.

They can be. Docs are correct. The types are probably wrong.

image

@brc-dd brc-dd added bug Something isn't working types Related to typings only and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jun 3, 2022
kecrily added a commit to kecrily/vitepress that referenced this issue Jun 3, 2022
kecrily added a commit to kecrily/vitepress that referenced this issue Jun 3, 2022
@zRains
Copy link
Contributor Author

zRains commented Jun 3, 2022

My solution:

export interface NavItemWithChildren {
  text: string
  items: {
    text?: string
    items: NavItemWithLink[]
  }[]
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working types Related to typings only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants