Skip to content

Conversation

@chenjiahan
Copy link
Member

Summary

  • Add LiteralUnion utility type to handle string literal unions with fallback types.
  • Use it for assetPrefix to improve type safety.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings October 23, 2025 09:43
@netlify
Copy link

netlify bot commented Oct 23, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 8184e2a
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68f9f8c921a6710008c3786f
😎 Deploy Preview https://deploy-preview-6416--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 66 (🟢 up 6 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

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 introduces a LiteralUnion utility type to improve TypeScript autocomplete for string literal unions while still accepting any string. The type is applied to the assetPrefix configuration property to provide better developer experience when using the 'auto' literal while maintaining type flexibility.

Key changes:

  • Added LiteralUnion<T extends U, U> utility type to enable autocomplete for specific string literals without restricting the type to only those literals
  • Updated OutputConfig.assetPrefix to use LiteralUnion<'auto', string> instead of string | 'auto'
  • Updated DevConfig.assetPrefix to use LiteralUnion<'auto', string> | boolean for consistency

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/types/utils.ts Adds the LiteralUnion utility type with reference to TypeScript issue
packages/core/src/types/config.ts Imports LiteralUnion and applies it to both OutputConfig.assetPrefix and DevConfig.assetPrefix properties

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@chenjiahan
Copy link
Member Author

Thanks for the review!

@chenjiahan chenjiahan merged commit f80bffc into main Oct 23, 2025
12 checks passed
@chenjiahan chenjiahan deleted the literral_union_1023 branch October 23, 2025 10:37
@chenjiahan chenjiahan mentioned this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants