@prismicio/types-internal 3.12.0-alpha.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,7 +123,7 @@ export function traverseSlices<T extends DynamicSlices | StaticSlices>(args: {
123
123
 
124
124
  if (!slices.config?.choices) return slices
125
125
 
126
- const choices: Record<string, typeof slices.config.choices[string]> = {}
126
+ let choices: Record<string, typeof slices.config.choices[string]> | undefined
127
127
  for (const [key, prevModel] of Object.entries(slices.config.choices)) {
128
128
  const path = [...prevPath, key]
129
129
  let model
@@ -165,14 +165,20 @@ export function traverseSlices<T extends DynamicSlices | StaticSlices>(args: {
165
165
  break
166
166
  }
167
167
 
168
- choices[key] = model as typeof slices.config.choices[string]
168
+ if (model !== prevModel) {
169
+ if (!choices) choices = { ...slices.config.choices }
170
+ choices[key] = model as typeof slices.config.choices[string]
171
+ }
169
172
  }
170
173
 
171
- return {
172
- ...slices,
173
- config: {
174
- ...slices.config,
175
- choices,
176
- },
177
- }
174
+ // returns the traversed model instead of a new one if it didn't change
175
+ return choices
176
+ ? {
177
+ ...slices,
178
+ config: {
179
+ ...slices.config,
180
+ choices,
181
+ },
182
+ }
183
+ : slices
178
184
  }