@trpc/server - Inferrence quirk with ProcedureInputParserCustomValidatorEsque<TInput>
See original GitHub issue@trpc/server
: 7.0.0
Typescript tested: 4.2.4 & 4.3.2
There is a small, but annoying quirk with inference on the ProcedureInputParserCustomValidatorEsque<TInput>
:
router()
.mutation("write", {
// 1. "a" parameter is inferred as unknown (=correct), but the return type is not inferred up the type tree
input: (a) => "x",
// 2. you need to explicitly type (a: unknown), for the inference of return type go up the tree:
// input: (a: unknown) => "x"
resolve({input}) {
// input is resolved as unknown in case 1. and correctly as "string" in 2. case
}
})
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing this as I won’t address it myself - if someone else experience problems related to this, feel free to nudge me on twitter.
@KATT Thanks. Its same issue type, as this next-auth issue. I’v PR’d a fix there. The issue is with the BC, I’ll check back on this too.