Fix verbose controller errors and brand type explosion#735
Draft
Fix verbose controller errors and brand type explosion#735
Conversation
…ream must return Stream Agent-Logs-Url: https://github.com/effect-app/libs/sessions/2c171f90-bae0-4147-a3a1-549204ad545b Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/2c171f90-bae0-4147-a3a1-549204ad545b Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
patroza
May 5, 2026 13:25
View session
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Controller handler errors were nearly useless: wrong error types triggered "overload" complaints (from Effect/Stream handler union alternatives), and all types were expanded — e.g.
NonEmptyString255showed asstring & B.Brand<"NonEmptyString255"> & B.Brand<"NonEmptyString2k"> & B.Brand<"NonEmptyString64k"> & ...instead of the named alias.Brand type aliases — drop
SimplifyAll brand types (
NonEmptyString*Brand,StringIdBrand,UrlBrand,Min3String255Brand,Int*Brand,PositiveNumber*Brand,EmailBrand,PhoneNumberBrand) converted frominterface extends Simplify<B.Brand<"X"> & Y>to plain intersection type aliases:Simplifywas merging the entire brand hierarchy into a single flattened mapped type, which TypeScript inlined in error output.Controller handlers — generators only
HandlerWithInputEffandHandlerWithInputStreamremoved from the handler union. Only generator functions are accepted. This ensures TypeScript reports exactly one failure with the right information instead of cycling through three overload candidates.For stream requests, the generator must now
returnaStream.Streamvalue (previously any value was accepted and coerced at runtime):router3R-inference updated to also capture the returned stream's R channel.All existing test handlers (arrow functions /
Effect.fnUntracedwrappers) converted to generator methods.