tcurdt
tcurdt
Explore posts from servers
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] HtmlEscapedString not rendering?
A little weird there is not giving a type error.
3 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] HtmlEscapedString not rendering?
This is because render() returns a reponse - not a HtmlEscapedString.
3 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] return type of request handler
So it's either
async function render(c) : Promise<HtlEscapedString> {
return (<body/>)
}

.get('/bar', async (c) => {
return c.html(render(c))
})
async function render(c) : Promise<HtlEscapedString> {
return (<body/>)
}

.get('/bar', async (c) => {
return c.html(render(c))
})
or
async function render(c) : Promise<Response> {
return c.html(<body/>)
}

.get('/bar', async (c) => {
return render(c)
})
async function render(c) : Promise<Response> {
return c.html(<body/>)
}

.get('/bar', async (c) => {
return render(c)
})
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] return type of request handler
OK, I get it now
No overload matches this call.
The last overload gave the following error.
Argument of type '(c: Context<Env, "/bar", BlankInput>) => Promise<HtmlEscapedString>' is not assignable to parameter of type 'H<Env, "/bar", BlankInput, HandlerResponse<any>>'.
Type '(c: Context<Env, "/bar", BlankInput>) => Promise<HtmlEscapedString>' is not assignable to type 'MiddlewareHandler<Env, "/bar", BlankInput>'.
Type 'Promise<HtmlEscapedString>' is not assignable to type 'Promise<void | Response>'.
Type 'HtmlEscapedString' is not assignable to type 'void | Response'.
No overload matches this call.
The last overload gave the following error.
Argument of type '(c: Context<Env, "/bar", BlankInput>) => Promise<HtmlEscapedString>' is not assignable to parameter of type 'H<Env, "/bar", BlankInput, HandlerResponse<any>>'.
Type '(c: Context<Env, "/bar", BlankInput>) => Promise<HtmlEscapedString>' is not assignable to type 'MiddlewareHandler<Env, "/bar", BlankInput>'.
Type 'Promise<HtmlEscapedString>' is not assignable to type 'Promise<void | Response>'.
Type 'HtmlEscapedString' is not assignable to type 'void | Response'.
c.html() returns a response and hence the mismatch.
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] route param validation with zod
Thanks for the help!
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] route param validation with zod
But that works, too
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] route param validation with zod
Would be nice if it would.
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] route param validation with zod
I assumed that the zValidator middleware would handle this by default
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] route param validation with zod
Perfect id: z.coerce.number() was the trick.
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] return type of request handler
but the tooling complains in 2)
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] return type of request handler
yet it works in 1)
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] return type of request handler
It seems like Promise<HtlEscapedString> is not a type that is valid to return
8 replies
HHono
Created by tcurdt on 5/24/2024 in #help
[solved] return type of request handler
Thanks, @Nico ... that wasn't the really the question though ... sorry, for the comment ... let me adjust this
8 replies