Replies: 2 comments 2 replies
-
Hi @brudil ! Yep, that use case makes sense, and it'd be great if you wanted to work on a PR. The https://github.com/stephenh/joist-ts/blob/main/packages/codegen/src/config.ts#L13 And then around in here: https://github.com/stephenh/joist-ts/blob/main/packages/codegen/src/EntityDbMetadata.ts#L348 Is probably a good place to do the config lookup and replace the default JS type with the config type. I could see eventually this becoming more complicated if users wanted to bring their own custom serde to the table, but since you're just using branded types, that at runtime are the same primitives anyway, afaiu we wouldn't need that yet. (Also, for testing, if you wanted to add an Thanks! |
Beta Was this translation helpful? Give feedback.
-
Custom types landed in https://github.com/stephenh/joist-ts/releases/tag/v1.87.0 and Serde landed in https://github.com/stephenh/joist-ts/releases/tag/v1.91.0 |
Beta Was this translation helpful? Give feedback.
-
We use branded/tagged types a lot across our codebase, allowing us to represent primitives that have been "blessed" in some way. A lot of the time this is used in conjunction with Zod.
It would be great if Joist could support configuration to specify a type for the codegen to use instead of the pg->ts mapped type.
This would essentially behave like the
superstruct
option withFieldConfig
but with no change to the setter/getter implementation itself, purely the resulting type for that field.I'll be curious to hear if this is something you would like Joist to entertain as I'd be happy to work on a PR.
Beta Was this translation helpful? Give feedback.
All reactions