diff --git a/packages/core/src/types/config.ts b/packages/core/src/types/config.ts index cd91be553f..63e50b5a66 100644 --- a/packages/core/src/types/config.ts +++ b/packages/core/src/types/config.ts @@ -51,6 +51,7 @@ import type { ConfigChain, ConfigChainMergeContext, ConfigChainWithContext, + LiteralUnion, MaybePromise, OneOrMany, Optional, @@ -1193,7 +1194,7 @@ export interface OutputConfig { * `auto` means use a relative path based on file location. * @default `server.base` */ - assetPrefix?: string | 'auto'; + assetPrefix?: LiteralUnion<'auto', string>; /** * Set the size threshold to inline static assets such as images and fonts. * By default, static assets will be Base64 encoded and inline into the page if @@ -1734,7 +1735,7 @@ export interface DevConfig { * similar to the [output.publicPath](https://rspack.rs/config/output#outputpublicpath) * config of Rspack. */ - assetPrefix?: string | boolean; + assetPrefix?: LiteralUnion<'auto', string> | boolean; /** * Whether to render progress bars to display the build progress. * @default false diff --git a/packages/core/src/types/utils.ts b/packages/core/src/types/utils.ts index 2b050a3d50..ef3ae7ffe6 100644 --- a/packages/core/src/types/utils.ts +++ b/packages/core/src/types/utils.ts @@ -6,6 +6,9 @@ export type MaybePromise = T | Promise; export type Optional = Omit & Partial>; +// https://github.com/microsoft/TypeScript/issues/29729 +export type LiteralUnion = T | (U & Record); + /** * Creates a type with readonly properties at the first and second levels only. */