Skip to content

fix: strip nested brands in PayloadOf - #49

Merged
jo16oh merged 2 commits into
mainfrom
fix/payload-of-nested-brand
Sep 24, 2026
Merged

jo16oh merged 2 commits into
mainfrom
fix/payload-of-nested-brand

Conversation

@jo16oh

@jo16oh jo16oh commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

PayloadOf stopped at a nested Val, so a handler returning PayloadOf<Order> still sent Money's brand to the client:

type Order = Val<"Order", { id: string; total: Money }>;
const body: PayloadOf<Order> = order;
const total: Money = body.total; // compiled, although nothing sealed it on this side
  • open every nested Val and every Rec to its payload in PayloadOf
  • Val.unwrap returns PayloadOf<V>, so its nested Vals are plain data too, as they are at run time
  • docs: say both strip the brand at every depth

Code that stops compiling

The old types claimed a brand the value never had, so these relied on the bug:

  • Order(Val.unwrap(order)) and Val.of(Val.unwrap(order)), when the payload holds a nested Val. Seal each nested Val first: Order({ ...raw, total: Money(raw.total) })
  • Patch<PayloadOf<V>> passed to patch. Use Patch<SeedOf<V>>

- `Val.unwrap` returns it too, so seal each nested Val before sealing the unwrapped payload again
@jo16oh jo16oh added bug Something isn't working breaking changes that break consumers documentation Improvements or additions to documentation and removed breaking changes that break consumers labels Sep 24, 2026
@jo16oh
jo16oh merged commit fa7fd71 into main Sep 24, 2026
2 checks passed
@jo16oh
jo16oh deleted the fix/payload-of-nested-brand branch September 24, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant