Uh oh!
There was an error while loading. Please reload this page.
feat(json-rpc-engine): Type-safe context inference - #6902
Conversation
83ab221 to
a45a3c5Compare
mcmire
left a comment
There was a problem hiding this comment.
Had one question about representing an invalid engine better, as well as some other comments. None of this is blocking though. I think this works really well.
Uh oh!
There was an error while loading. Please reload this page.
| it('type errors and returns undefined when getting unknown keys', () => { | ||
| const context = new MiddlewareContext<{ test: string }>(); | ||
| // @ts-expect-error - foo is not a valid key |
There was a problem hiding this comment.
Nit: Would it be worth adding tsd or tstyche tests at some point for some of these classes? This would allow us to write assertions at the type level.
There was a problem hiding this comment.
I think we're squeaking by with @ts-expect-error for now, although I'm not opposed to the idea if we think it becomes warranted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
471ff5e
into
rekm/json-rpc-engine-rewrite-nextUh oh!
There was an error while loading. Please reload this page.
Explanation
References
Checklist
Note
Introduce generic, type-safe MiddlewareContext and JsonRpcEngineV2.create() factory with improved type inference; update server, utils/exports, tests, and docs accordingly.
JsonRpcEngineV2.create()static factory; make constructor private and enforce non-empty middleware.Context,ResultConstraint; improved request/notification typing and composition.handle()/asMiddleware(); validate incompatible contexts at type level; new internal invalid-engine typing.MiddlewareContextgeneric with strict key/value typing; addassertGet/settypings,EmptyContext, andMergeContextsutil.Json,JsonRpcParams; addUnionToIntersectiontype.JsonRpcEngineErrorwith cross-versionisInstance().create()when passed middleware; clarify/adjust param validation and id handling.propagateToContextto accept typed context; minor param-handling tweaks.create()and new helper middlewares; add coverage for context typing, invalid compositions, and new behaviors.create(), typed middleware/context, composition patterns, and error semantics.Written by Cursor Bugbot for commit 75f61e7. This will update automatically on new commits. Configure here.