Closed justin0mcateer closed 3 months ago
It's a good point. The closest you can use is the rescript documentation https://github.com/DZakh/rescript-schema/blob/main/docs/rescript-usage.md#union TS code should look pretty much the same. I don't remember if I added s.tag support, but you can use s.field("", S.literal()) instead
I've got an idea of how to make it even more ergonomic and convenient for the JS/TS users. I'll add the feature in the next version together with the documentaion.
Awesome!
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Dmitry Zakharov @.> Sent: Sunday, August 25, 2024 1:31:23 PM To: DZakh/rescript-schema @.> Cc: justin0mcateer @.>; Author @.> Subject: Re: [DZakh/rescript-schema] Documentation for Discriminated Unions in TypeScript (Issue #86)
I've got an idea of how to make it even more ergonomic and convenient for the JS/TS users. I'll add the feature in the next version together with the documentaion.
— Reply to this email directly, view it on GitHubhttps://github.com/DZakh/rescript-schema/issues/86#issuecomment-2308951582, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAT4Q7IJ6PWTACQ7KABLY6LZTIPHXAVCNFSM6AAAAABM2SMWUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHE2TCNJYGI. You are receiving this because you authored the thread.Message ID: @.***>
Here's the documentation update for the feature: https://github.com/DZakh/rescript-schema/commit/4b0d45625b3e81515586083cf9600b0b164b427b
I'll release it as 8.1.0
after ci finishes running.
Published
I did get it working, based on your previous pointers.
The new approach you documented looks very concise. Love it!
Thanks for your hard work. I have been looking forward to using this library for a while. Starting my first project with it, things are going pretty well, very easy to use and quite powerful.
One issue I have run into is it's not clear to me what is the correct way to implement discriminated unions. I found some older issues which referenced 'discriminator' and 'field' with 'ignore'. I wasn't really able to put any of this into practice. Some specific documentation on discriminated types in the TypeScript documentation would be super helpful.