Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug(server): input matching
{ description?: string }
breaks built p…
…rocedure (#5297) --------- Co-authored-by: Alex / KATT <alexander@n1s.se>
- Loading branch information
1 parent
fc3e467
commit 65d8afa
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
49 changes: 49 additions & 0 deletions
49
packages/tests/server/regression/issue-5297-description-key-on-input-turns-to-void.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { QueryProcedure } from '@trpc/core'; | ||
import { initTRPC } from '@trpc/server'; | ||
import * as z from 'zod'; | ||
|
||
describe('Serialization of Record types', () => { | ||
const t = initTRPC.create(); | ||
const appRouter = t.router({ | ||
withDescriptionKey: t.procedure | ||
.input( | ||
z.object({ | ||
description: z.string(), | ||
}), | ||
) | ||
.query(({ input }) => { | ||
expectTypeOf<{ description: string }>(input); | ||
return { input }; | ||
}), | ||
maybeDescriptionKey: t.procedure | ||
.input( | ||
z.object({ | ||
description: z.string().optional(), | ||
}), | ||
) | ||
.query(({ input }) => { | ||
expectTypeOf<{ description?: string }>(input); | ||
return { input }; | ||
}), | ||
}); | ||
|
||
test("Description key doesn't get matched on unsetMarker", async () => { | ||
expectTypeOf< | ||
QueryProcedure<{ | ||
input: { | ||
description: string; | ||
}; | ||
output: { input: { description: string } }; | ||
}> | ||
>(appRouter.withDescriptionKey); | ||
|
||
expectTypeOf< | ||
QueryProcedure<{ | ||
input: { | ||
description?: string | undefined; | ||
}; | ||
output: { input: { description?: string | undefined } }; | ||
}> | ||
>(appRouter.maybeDescriptionKey); | ||
}); | ||
}); |
65d8afa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
trpc-next-app-dir – ./examples/.experimental/next-app-dir
trpc-next-app-dir-git-next-trpc.vercel.app
trpc-next-app-dir-trpc.vercel.app
trpc-next-app-dir.vercel.app
65d8afa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
www – ./www
next.trpc.io
trpc.io
www-git-next-trpc.vercel.app
beta.trpc.io
alpha.trpc.io
www.trpc.io
www-trpc.vercel.app