fix(rpc): favour zod types only #828
Open
+370
−224
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.
Figuring out best way to handle some message passing and continually running into need to runtime check a payload & narrow the type. This is only possible if all method requests and response are available as schemas. I regret setting up this type structure and not going validator first from the start.
I know we don't follow the convention of "section comments" like I've used here, but find schema heavy files hard to navigate without.
There's a pretty crazy type overload here. The tricky part is that some methods do / do not have params defined. And, based on whether or not a params schema is defined, the inferred type should know whether or not there's a params object. I tried using a conditional type e.g.
TParams extends undefined ? X : Y
but it didn't infer correctly.