File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ import type {
4747 ConfigChain ,
4848 ConfigChainMergeContext ,
4949 ConfigChainWithContext ,
50- DeepReadonly ,
5150 MaybePromise ,
5251 OneOrMany ,
52+ TwoLevelReadonly ,
5353} from './utils' ;
5454
5555export type ToolsSwcConfig = ConfigChain < SwcLoaderOptions > ;
@@ -1802,7 +1802,7 @@ export type MergedEnvironmentConfig = {
18021802/**
18031803 * The normalized Rsbuild environment config.
18041804 */
1805- export type NormalizedEnvironmentConfig = DeepReadonly <
1805+ export type NormalizedEnvironmentConfig = TwoLevelReadonly <
18061806 Omit < MergedEnvironmentConfig , 'dev' > & {
18071807 dev : NormalizedDevConfig ;
18081808 server : NormalizedServerConfig ;
Original file line number Diff line number Diff line change @@ -4,9 +4,16 @@ export type OneOrMany<T> = T | T[];
44
55export type MaybePromise < T > = T | Promise < T > ;
66
7- export type DeepReadonly < T > = keyof T extends never
7+ /**
8+ * Creates a type with readonly properties at the first and second levels only.
9+ */
10+ export type TwoLevelReadonly < T > = keyof T extends never
811 ? T
9- : { readonly [ k in keyof T ] : DeepReadonly < T [ k ] > } ;
12+ : {
13+ readonly [ k in keyof T ] : T [ k ] extends object
14+ ? { readonly [ p in keyof T [ k ] ] : T [ k ] [ p ] }
15+ : T [ k ] ;
16+ } ;
1017
1118export type ConfigChain < T > = OneOrMany < T | ( ( config : T ) => T | void ) > ;
1219
You can’t perform that action at this time.
0 commit comments