Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/effect/src/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,20 @@ export declare namespace TaggedEnum {
* ```
*
* @example
* ```ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to just have one example. Feel free to remove the other one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My example is indeed more concise and looks like a better practice. You suggest that the old example should be removed? How do you document such valid extra cases then?

* import { Data } from "effect"
*
* type HttpError = Data.TaggedEnum<{
* BadRequest: { readonly status: 400; readonly message: string }
* NotFound: { readonly status: 404; readonly message: string }
* }>
*
* const { BadRequest, NotFound } = Data.taggedEnum<HttpError>()
*
* const notFound = NotFound({ status: 404, message: "Not Found" })
* ```
*
* @example
* import { Data } from "effect"
*
* type MyResult<E, A> = Data.TaggedEnum<{
Expand Down
Loading