Skip to content

🏷️ Type SubmitRequest's fields and derive SubmitContext from them - #806

Draft
alecgibson wants to merge 1 commit into
mainfrom
worktree-humming-wibbling-metcalfe
Draft

alecgibson wants to merge 1 commit into
mainfrom
worktree-humming-wibbling-metcalfe

Conversation

@alecgibson

Copy link
Copy Markdown
Collaborator

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)

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)
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 98.105% (+0.001%) from 98.104% — worktree-humming-wibbling-metcalfe into main

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type SubmitRequest's fields and derive SubmitContext from them

2 participants