Repository navigation
🏷️ Type SubmitRequest's fields and derive SubmitContext from them - #806
Draft
alecgibson wants to merge 1 commit into
Draft
alecgibson wants to merge 1 commit into
alecgibson wants to merge 1 commit into
Conversation
Fixes #795 At the moment, `SubmitRequest`'s fields are untyped, so our declarations emit them as `any`, and `middleware.SubmitContext` lists the same fields again by hand. So `submitRequestEnd` listeners and `backend.submit()`'s callback get an untyped `request`, and nothing keeps the two lists in step. This change types the fields on the class, and picks `SubmitContext`'s from it. The emitted JS doesn't change, so the method bodies cast `op`, now the `CreateOp | DeleteOp | EditOp` union, to read a member, rather than narrowing it with `in`. Middleware's types don't change, but code that reads `request.op.create` outside middleware now has to narrow `op` first. 🤖 Generated with Claude Code (Claude Opus 5.5)
This branch has not been deployed
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.
Fixes #795
At the moment,
SubmitRequest's fields are untyped, so our declarations emit them asany, andmiddleware.SubmitContextlists the same fields again by hand. SosubmitRequestEndlisteners andbackend.submit()'s callback get an untypedrequest, and nothing keeps the two lists in step.This change types the fields on the class, and picks
SubmitContext's from it. The emitted JS doesn't change, so the method bodies castop, now theCreateOp | DeleteOp | EditOpunion, to read a member, rather than narrowing it within.Middleware's types don't change, but code that reads
request.op.createoutside middleware now has to narrowopfirst.🤖 Generated with Claude Code (Claude Opus 5.5)