You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, great generator! As a frontend dev it is very convenient to simply import all route typesafe from the backend without having to write all types twice!
However, when trying it out, I noticed a problem with Date: With a controller that has a Date object as type, the generator copies it as such. But Nest.js automatically transforms this to an ISO string, whereby the client type is no longer correct (Date instead of string).
// GET /demo/route
{
"id": 3,
"date": "2023-09-24T15:14:48.940Z"
}
Generated SDK:
exportdefault{// GET @ /demo/routedemo(params: {}={},body: {}={},query: {}={},): Promise<{id: number;date: Date}>{returnrequest("GET",`/demo/route`,body,query)},}
Usage:
const{ date }=awaitdemoController.demo();// throws Uncaught TypeError: date.toLocaleDateString is not a functionconsole.log(date.toLocaleDateString())
Would it be possible (and if so how) to transform these Date objects automatically on the client side? Either change all Date types to strings, or ideally recursively parse them directly with new Date(value).
The text was updated successfully, but these errors were encountered:
Hey, great generator! As a frontend dev it is very convenient to simply import all route typesafe from the backend without having to write all types twice!
However, when trying it out, I noticed a problem with Date: With a controller that has a
Date
object as type, the generator copies it as such. But Nest.js automatically transforms this to an ISO string, whereby the client type is no longer correct (Date
instead ofstring
).Example
Controller:
Response:
Generated SDK:
Usage:
Would it be possible (and if so how) to transform these
Date
objects automatically on the client side? Either change allDate
types tostring
s, or ideally recursively parse them directly withnew Date(value)
.The text was updated successfully, but these errors were encountered: