diff --git a/packages/core/src/types/config.ts b/packages/core/src/types/config.ts index 5e1209714e..0fe5578fd0 100644 --- a/packages/core/src/types/config.ts +++ b/packages/core/src/types/config.ts @@ -52,6 +52,7 @@ import type { ConfigChainWithContext, MaybePromise, OneOrMany, + Optional, TwoLevelReadonly, } from './utils'; @@ -535,22 +536,13 @@ export interface ServerConfig { export type NormalizedServerConfig = { publicDir: Required[]; -} & Pick & - Required< - Pick< - ServerConfig, - | 'htmlFallback' - | 'port' - | 'host' - | 'compress' - | 'strictPort' - | 'printUrls' - | 'open' - | 'base' - | 'cors' - | 'middlewareMode' - > - >; +} & Omit< + Optional< + Required, + 'headers' | 'https' | 'historyApiFallback' | 'proxy' + >, + 'publicDir' +>; export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512'; @@ -1320,8 +1312,7 @@ export interface OutputConfig { export interface NormalizedOutputConfig extends OutputConfig { target: RsbuildTarget; filename: FilenameConfig; - distPath: Omit, 'jsAsync' | 'cssAsync' | 'js'> & - Pick; + distPath: Optional, 'jsAsync' | 'cssAsync' | 'js'>; polyfill: Polyfill; sourceMap: | boolean @@ -1698,8 +1689,10 @@ export type ClientConfig = { overlay?: boolean; }; -export type NormalizedClientConfig = Pick & - Omit, 'protocol'>; +export type NormalizedClientConfig = Optional< + Required, + 'protocol' +>; export type { ChokidarOptions }; @@ -2000,10 +1993,7 @@ export type MergedEnvironmentConfig = { resolve: NormalizedResolveConfig; source: NormalizedSourceConfig; output: Omit & { - distPath: Omit, 'jsAsync' | 'cssAsync'> & { - jsAsync?: string; - cssAsync?: string; - }; + distPath: Optional, 'jsAsync' | 'cssAsync'>; }; plugins?: RsbuildPlugins; security: NormalizedSecurityConfig; diff --git a/packages/core/src/types/utils.ts b/packages/core/src/types/utils.ts index e1571176dd..2b050a3d50 100644 --- a/packages/core/src/types/utils.ts +++ b/packages/core/src/types/utils.ts @@ -4,6 +4,8 @@ export type OneOrMany = T | T[]; export type MaybePromise = T | Promise; +export type Optional = Omit & Partial>; + /** * Creates a type with readonly properties at the first and second levels only. */