Skip to content

Commit

Permalink
fix: Make serializeService work with services that don't throw (#31)
Browse files Browse the repository at this point in the history
Turns out that when the `errors` field is `TNever`, the field is not
emitted!

This change allows infallible services to service.
  • Loading branch information
lhchavez authored Dec 12, 2023
1 parent 4360cc8 commit 105cc11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@replit/river",
"sideEffects": false,
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.9.0",
"version": "0.9.1",
"type": "module",
"exports": {
".": "./dist/router/index.js",
Expand Down
7 changes: 6 additions & 1 deletion router/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export function serializeService(s: AnyService): object {
{
input: Type.Strict(procDef.input),
output: Type.Strict(procDef.output),
errors: Type.Strict(procDef.errors),
// Only add the `errors` field if it is non-never.
...('errors' in procDef
? {
errors: Type.Strict(procDef.errors),
}
: {}),
type: procDef.type,
// Only add the `init` field if the type declares it.
...('init' in procDef
Expand Down

0 comments on commit 105cc11

Please sign in to comment.