Skip to content

Conversation

@EasonLin0716
Copy link

@EasonLin0716 EasonLin0716 commented Jun 23, 2025

I noticed that this project doesn’t use component.d.ts to map Naive UI to its corresponding components, so I’m submitting this PR. This change doesn’t affect any business logic, but I believe it will be helpful for developers who rely on IDE auto-completion for component props. Theoretically, after installing this plugin, it’s possible to remove app.use(naive), but I didn’t make that change out of caution, in case there are any side effects.

image

Summary by CodeRabbit

  • New Features
    • Enabled automatic global registration and type recognition of Naive UI and custom components in Vue templates, eliminating the need for manual imports.
  • Chores
    • Added a new development dependency to support automatic component imports.
    • Updated TypeScript configuration to include new component type declarations.
    • Enhanced build configuration to support auto-import of UI components.

@coderabbitai
Copy link

coderabbitai bot commented Jun 23, 2025

Walkthrough

A global TypeScript declaration file was introduced to register Vue components for automatic type recognition. The project configuration was updated to include this declaration file in the TypeScript build and to add the unplugin-vue-components plugin with Naive UI resolver in Vite. The plugin was also added as a development dependency.

Changes

File(s) Change Summary
components.d.ts Added TypeScript module augmentation for global registration and typing of Vue and Naive UI components.
package.json Added unplugin-vue-components as a development dependency.
tsconfig.app.json Included components.d.ts in files processed by the TypeScript compiler.
vite.config.ts Integrated unplugin-vue-components with Naive UI resolver into the Vite plugins array.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Vite as Vite Build
    participant Plugin as unplugin-vue-components
    participant Naive as Naive UI Components
    participant TS as TypeScript

    Dev->>Vite: Runs build or dev server
    Vite->>Plugin: Loads plugins (including vue, vueJsx, mock, unplugin-vue-components)
    Plugin->>Naive: Resolves and auto-imports Naive UI components
    Vite->>TS: Compiles source, includes components.d.ts
    TS->>Dev: Provides global component types in templates
Loading

Poem

In the warren of code, a new path appears,
Components now register, allaying our fears.
With Naive UI hopping in, and plugins in tow,
TypeScript knows every bunny, wherever you go.
Vite brews the magic, dependencies align—
Now templates are tidy, and everything’s fine!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
components.d.ts (1)

9-52: LGTM! Comprehensive component declarations.

The global component declarations are comprehensive, covering Naive UI components, custom components, and router components with proper TypeScript typing.

Consider adding components.d.ts to .gitignore since it's an auto-generated file:

+# Auto-generated component declarations
+components.d.ts
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3dda5a2 and fc72d7e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components.d.ts (1 hunks)
  • package.json (1 hunks)
  • tsconfig.app.json (1 hunks)
  • vite.config.ts (2 hunks)
🔇 Additional comments (5)
package.json (1)

57-57: Verify the package version is correct.

The version ^28.7.0 for unplugin-vue-components seems unusually high. Please verify this is the correct version.

What is the latest version of unplugin-vue-components package?
tsconfig.app.json (1)

3-3: LGTM! Proper TypeScript integration.

Correctly adds the components declaration file to the TypeScript compilation scope, enabling global component type recognition.

vite.config.ts (2)

9-10: LGTM! Proper plugin imports.

Correctly imports the Components plugin and NaiveUiResolver for automatic component registration.


43-47: LGTM! Standard plugin configuration.

The Components plugin configuration with NaiveUiResolver follows the standard pattern for Naive UI integration.

components.d.ts (1)

1-6: LGTM! Proper generated file configuration.

The ESLint and TypeScript ignores are appropriate for this auto-generated file.

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.

1 participant