Skip to content

refactor: migrate types to use rspack/core definitions#158

Merged
chenjiahan merged 2 commits intomainfrom
ref_types_0312
Mar 12, 2026
Merged

refactor: migrate types to use rspack/core definitions#158
chenjiahan merged 2 commits intomainfrom
ref_types_0312

Conversation

@chenjiahan
Copy link
Member

  • move type definitions from local types to @rspack/core for better maintainability
  • update imports and type references to align with rspack/core
  • move @types/serve-static from dependencies to devDependencies

Copilot AI review requested due to automatic review settings March 12, 2026 04:59
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant refactoring of type definitions within the project. The primary goal is to centralize type management by migrating local type declarations to the @rspack/core package. This change enhances maintainability by reducing duplication and ensuring that the project's type system is consistently aligned with the core Rspack definitions. Additionally, it includes a minor dependency adjustment to correctly classify a type package.

Highlights

  • Type Definition Migration: Moved numerous local type definitions to use the canonical types provided by @rspack/core for improved consistency and maintainability across the codebase.
  • Dependency Refactoring: Adjusted the package.json and pnpm-lock.yaml to correctly categorize @types/serve-static as a devDependencies instead of a dependencies.
  • Codebase Alignment: Updated type imports and references across src/config.ts, src/server.ts, and src/types.ts to align with the new @rspack/core type definitions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • package.json
    • Moved @types/serve-static from dependencies to devDependencies.
  • pnpm-lock.yaml
    • Updated lockfile to reflect the change in @types/serve-static dependency.
  • src/config.ts
    • Removed import for local ClientConfiguration type.
    • Added import for DevServerClient type from @rspack/core.
    • Updated the client property type in ResolvedDevServer from ClientConfiguration to DevServerClient.
  • src/server.ts
    • Added new type imports from @rspack/core including App, HandleFunction, NextFunction, NextHandleFunction, SimpleHandleFunction, DevServerHost, DevServerHeaders, DevServerClient, DevServerStaticItem, DevServerMiddlewareHandler, DevServerWebSocketURL, DevServerProxyConfigArray, DevServerProxyConfigArrayItem, and DevServerStatic.
    • Removed various local type imports that are now sourced from @rspack/core or connect-next.
    • Updated type references for host, client, webSocketURL, static, proxy, and middleware properties to use the new @rspack/core definitions.
  • src/types.ts
    • Removed numerous local type definitions such as NextFunction, SimpleHandleFunction, HandleFunction, Host, Static, ProxyConfigArrayItem, ProxyConfigArray, OpenApp, WebSocketURL, ClientConfiguration, Headers, and MiddlewareHandler.
    • Imported DevServerMiddlewareHandler, DevServerOpenOptions, and DevServerStaticItem from @rspack/core.
    • Imported ErrorHandleFunction, HandleFunction, and NextHandleFunction from connect-next.
    • Updated NormalizedStatic's staticOptions type to DevServerStaticItem['staticOptions'].
    • Modified the Open type to extend DevServerOpenOptions.
    • Adjusted the middleware property type within MiddlewareObject and the Middleware type itself to use DevServerMiddlewareHandler or ErrorHandleFunction.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the dev-server’s TypeScript surface to rely on @rspack/core’s dev-server type definitions instead of locally maintained copies, reducing duplication and keeping the package aligned with core’s evolving API.

Changes:

  • Migrated several dev-server-related option/types (client/static/proxy/headers/host/middleware/open) to @rspack/core definitions.
  • Simplified local type declarations in src/types.ts by removing duplicated connect/static/proxy/client/open type shapes.
  • Moved @types/serve-static from dependencies to devDependencies.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/types.ts Removes duplicated local types and reuses @rspack/core + connect-next type definitions.
src/server.ts Updates configuration and internal type assertions to use @rspack/core dev-server types.
src/config.ts Aligns resolved config typing with DevServerClient from @rspack/core.
package.json Moves @types/serve-static to devDependencies.
pnpm-lock.yaml Lockfile update reflecting the dependency move.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan merged commit 749ee50 into main Mar 12, 2026
3 checks passed
@chenjiahan chenjiahan deleted the ref_types_0312 branch March 12, 2026 06:11
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