-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to define "branded" types. #193
Comments
Tracked in #17. I intend to support this in Specta v2 (mostly to avoid the need for Specta v3) but it's worth noting Serde doesn't support const parameters.
It's hacky but this is possible (and sadly is something we do in Spacedrive). If you're using 2.0.0-rc.x releases you will need to use Getting access to the This is the sorta feature that probably needs its own higher-level abstraction outside of the specta core crate.
Right now you would have to do this manually after Specta runs. Tauri Specta has a I created #202 to track this
I'm honestly not sure we have a way to express this at the moment. It could be done with #110 or #17 but neither are supported at the moment and both have unanswered questions about exactly how I would want them to work. |
A correction to the bit about the |
I am currently searching for a way to map TypeScript branded types, like https://github.com/kourge/ts-brand cleanly using specta. My current (flawed) approach is:
Which reduces to:
Now, this is not ideal due to several factors:
export Type Brand<T>
import {Brand} from ts-brand;
(not that bad)adt_const_params
, which is incomplete.What I would love (in a perfect world) would be something similar to:
How would I approach this problem? Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: