Environment
Apologies if I am misunderstanding something here but going crazy trying to figure out how to type serialization/deserialization for OpenAPI contracts. Below is a simple reproduction of a created Date field which I believe is incorrectly typed.
https://stackblitz.com/edit/github-wanxqepn-jbdy8pb5?file=src%2Flib%2Forpc.ts,src%2Fplayground-client.ts
"name": "@orpc/nest-playground",
"version": "1.13.4",
"private": true,
"scripts": {
"preview": "nest build && unbuild --stub && node dist/main.mjs",
"start:dev": "nest start --watch",
"type:check": "tsc --noEmit"
},
"devDependencies": {
"@nestjs/cli": "^11.0.16",
"@nestjs/common": "^11.1.12",
"@nestjs/core": "^11.1.12",
"@nestjs/platform-express": "^11.1.12",
"@nestjs/schematics": "^11.0.9",
"@orpc/client": "next",
"@orpc/contract": "next",
"@orpc/json-schema": "next",
"@orpc/nest": "next",
"@orpc/openapi": "next",
"@orpc/openapi-client": "next",
"@orpc/tanstack-query": "next",
"@orpc/zod": "next",
"@swc/cli": "^0.7.10",
"@swc/core": "^1.15.10",
"@tanstack/react-query": "^5.90.20",
"@types/express": "^5.0.6",
"@types/node": "^22.19.3",
"globals": "^17.1.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"source-map-support": "^0.5.21",
"ts-loader": "^9.5.4",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "~5.9.3",
"unbuild": "^3.6.1",
"zod": "^4.3.6"
}
}
Reproduction
What I have setup to showcase the issue
- added a
created?: z.coerce.date() field to the planet schema
- created a non
ResponseValidationPlugin and a ResponseValidationPlugin client in playground-client.ts
In the playground you can see that using z.coerce.date() with ResponseValidationPlugin - it still iis typed as string in the tanstack query output.
If we mean to do this when not using ResponseValidationPlugin that may make sense as the field would be a string until it is validated.
However, I would expect that when using ResponseValidationPlugin the types would match type planetOutput = OrpcOutput['planet']['find']; - in the playground you can see OrpcOutput does type it as a Date.
https://stackblitz.com/edit/github-wanxqepn-jbdy8pb5?file=src/lib/orpc.ts,src/playground-client.ts,package.json
Describe the bug
In the playground you can see that using z.coerce.date() with ResponseValidationPlugin - it still iis typed as string in the tanstack query output through it should be Date since we are transforming it.
Additional context
No response
Logs
Environment
Apologies if I am misunderstanding something here but going crazy trying to figure out how to type serialization/deserialization for OpenAPI contracts. Below is a simple reproduction of a
createdDate field which I believe is incorrectly typed.https://stackblitz.com/edit/github-wanxqepn-jbdy8pb5?file=src%2Flib%2Forpc.ts,src%2Fplayground-client.ts
Reproduction
What I have setup to showcase the issue
created?: z.coerce.date()field to the planet schemaResponseValidationPluginand aResponseValidationPluginclient in playground-client.tsIn the playground you can see that using
z.coerce.date()with ResponseValidationPlugin - it still iis typed as string in the tanstack query output.If we mean to do this when not using ResponseValidationPlugin that may make sense as the field would be a string until it is validated.
However, I would expect that when using ResponseValidationPlugin the types would match
type planetOutput = OrpcOutput['planet']['find'];- in the playground you can see OrpcOutput does type it as a Date.https://stackblitz.com/edit/github-wanxqepn-jbdy8pb5?file=src/lib/orpc.ts,src/playground-client.ts,package.json
Describe the bug
In the playground you can see that using
z.coerce.date()with ResponseValidationPlugin - it still iis typed as string in the tanstack query output through it should be Date since we are transforming it.Additional context
No response
Logs