Search
Setup for Free
K
Kysely
•
3y ago
thelinuxlich
How do I cast the type of a eb.fn('...') ?
I tried with eb
.fn
<string
>
(
"CONCAT
"
,
[
.
.
.
.
]
) but it didn
't worked
Solution
If it doesn
't work for some reason
, you can use
eb.fn('now', []).$castTo<Date>()
eb.fn('now', []).$castTo<Date>()
Jump to solution
Kysely
Join
First came Kysely, the type-safe query builder for TypeScript, then came people asking questions, then came the Discord server.Join if you like Kysely or have questions, or both.
2,006
Members
View on Discord
Similar Threads
Was this page helpful?
Yes
No
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
eb.
fn
(
'now'
, []).
$castTo
<
Date
>()
eb.
fn
(
'now'
, []).
$castTo
<
Date
>()
K
koskimas
•
10/17/23, 2:49 PM
That should work I think
K
koskimas
•
10/17/23, 2:49 PM
Works here
https://kyse.link/?p=s&i=t6D3BH87tCkm2j44jVT5
K
koskimas
•
10/17/23, 2:49 PM
Can you modify that to make it not work
?
Solution
K
koskimas
•
10/17/23, 5:20 PM
If it doesn
't work for some reason
, you can use
eb.
fn
(
'now'
, []).
$castTo
<
Date
>()
eb.fn('now', []).$castTo<Date>()
T
thelinuxlich
OP
•
10/17/23, 5:24 PM
in my case it
's inside a case
(
)
.
.
.but I
'm baffled it works on the playground but not on my side
https://kyse.link/?p=s&i=t6D3BH87tCkm2j44jVT5
T
thelinuxlich
OP
•
10/17/23, 5:29 PM
and now it works on my side too
, after I cleared a field and autocompleted it
.
.
.TS shenanigans
eb.
fn
(
'now'
, []).
$castTo
<
Date
>()
Similar Threads
eb.fn.coalesce on a subquery
K
Kysely / help
16mo ago
I need to extract the type of eb in the query chain
K
Kysely / help
8mo ago
How do I type the arguments to a function?
K
Kysely / help
3y ago