This repository was archived by the owner on Oct 7, 2026. It is now read-only.
Repository navigation
fix: keep zod's brand nameable through DeepReadonly - #156
Merged
Merged
Conversation
DeepReadonly mapped a branded object whole, turning its brand into a computed `[$brand]` key over zod's unique symbol. Wherever a consumer's declaration emit had to print that type expanded, such as an exported factory of an entity with a nested-entity field, emit failed with TS4023 on both 7.0.2 and 5.9.3. Peel the brand, map the rest, and re-intersect `z.core.$brand<B>`, which prints by name. The billing fixture now exports `Order.factory` as the regression guard; the fix alone shrinks its emitted declarations by 155 bytes. Closes #152 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DeepReadonlymapped a branded object (z.object(…).brand("Money")) as a whole. The brand became{ readonly [$brand]: … }, a computed key over zod'sunique symbol, and a downstream declaration emit cannot name that (TS4023). It only surfaced where the emitter has to printDeepReadonlywritten out in full, such as an exportedX.factory(...)whose input contains a nested entity's instance type. Branded object fields break declaration emit with TS4020 (OnlyNominal accepts them) #32 hit the same root through a different path.DeepReadonly<Omit<T, typeof $brand>> & z.core.$brand<B>, which prints asz.$brand<"Money">. Branded primitives still short-circuit throughImmutable. The Branded object fields break declaration emit with TS4020 (OnlyNominal accepts them) #32 guard (invoice.total.amount = 1is a compile error) still holds, since its@ts-expect-erroris still used.examples/billing-domainnow exportscreateOrder = Order.factory(...)directly. It failed before the fix with TS4023 on 7.0.2 and 5.9.3, and it is checked by both declaration-emit passes plus the 5.9.3 check of the emitted output. This removes docs(aggregate): draw ownership, reference and snapshot boundaries #151's private-factory workaround..d.tsfrom 40,863 to 40,708 bytes (−155 B). The newcreateOrderexport adds 2.4 KB of its own. There are still zeroGeneratedKeys</ImmutableKeys<in the output.Closes #152
Test plan
Order.factoryfailedtsc -p tsconfig.emit.jsonwith TS4023.test-d.tsand both emit passes), test (forced), knip, build🤖 Generated with Claude Code