Skip to content

Instantly share code, notes, and snippets.

@hxtree
Created January 5, 2026 05:10
Show Gist options
  • Select an option

  • Save hxtree/4b6af8affd602bc8f3cdf6daa46ee7e8 to your computer and use it in GitHub Desktop.

Select an option

Save hxtree/4b6af8affd602bc8f3cdf6daa46ee7e8 to your computer and use it in GitHub Desktop.
// Recursive personalization contract
export type Personalization<T> = {
type: "merge" | "replace"; // merge = selective, replace = full
value: Partial<T> | T;
nested?: { [K in keyof T]?: Personalization<T[K]> };
};
const itemListPersonalization: Personalization<ItemListProps> = {
type: "merge", // merge at the list level
nested: {
items: {
type: "merge", // merge the items array
nested: {
2: { // 0-based index → Item 3
type: "replace", // fully replace this item
value: {
title: "Completely New Item 3",
button: { label: "Buy Now", color: "red" },
},
},
},
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment