Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion packages/ui-scripts/lib/build/buildThemes/generateSemantics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,27 @@ export const resolveTypeReferences = (semantics: any, key?: any): string => {
return `${typeof value}, `
}

const deepMerge = (target: any, source: any): any => {
const result = { ...target }
for (const key of Object.keys(source)) {
if (
typeof source[key] === 'object' &&
source[key] !== null &&
!Array.isArray(source[key]) &&
typeof target[key] === 'object' &&
target[key] !== null &&
!Array.isArray(target[key])
) {
result[key] = deepMerge(target[key], source[key])
} else {
result[key] = source[key]
}
}
return result
}

export const mergeSemanticSets = (semanticList: any[]) =>
semanticList.reduce((acc, semantic) => ({ ...acc, ...semantic }), {})
semanticList.reduce((acc, semantic) => deepMerge(acc, semantic), {})
Comment thread
matyasf marked this conversation as resolved.

const generateSemantics = (data: any): string => {
const formattedSemantic = formatSemantic(data)
Expand Down
Loading