-
Notifications
You must be signed in to change notification settings - Fork 15
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
Allow boolean literals in enums #120
Allow boolean literals in enums #120
Conversation
I'm still unconvinced with this PR, can you explain to me more around the motivation of this PR and why you can't persue the current alternatives? |
The motivation is that it'd be an easy way to support result types for usecases of reporting datastore errors, roblox api errors, ect, to the client. Plus this is more intended to be a quick fix, as I'd like to not have to use "false" and "true" strings. That don't even atleast coerce into booleans in luau. And this can be replaced with a better syntax in the rewrite, and I'd like to not fully properly implement a solution as this can be just made better in the rewrite. |
Just out of curiosity, what syntax would you suggest in the rewrite?
… On 14 Jul 2024, at 11:35 am, Kalrnlo ***@***.***> wrote:
I'm still unconvinced with this PR, can you explain to me more around the motivation of this PR and why you can't persue the current alternatives?
The motivation is that it'd be an easy way to support result types for usecases of reporting datastore errors, roblox api errors, ect, to the client. Plus this is more intended to be a quick fix, as I'd like to not have to use "false" and "true" strings. That don't even atleast coerce into booleans in luau. And this can be replaced with a better syntax in the rewrite, and I'd like to not fully properly implement a solution as this can be just made better in the rewrite.
—
Reply to this email directly, view it on GitHub <#120 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AKQU3TGVGXZG5JKCUI57S33ZMHIXRAVCNFSM6AAAAABKPWNCVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRXGE3DAMZYGQ>.
You are receiving this because you commented.
|
Probably a result type, something like
that'd then serialize into type MyResult = {
success: true,
-- whatever is included in value_on_sucess, if value_on_sucess is just like a singular type ie u8 or u8 then it will create a value field
} | {
success: false,
-- same as the success side but using value_on_fail
} |
Co-authored-by: Sasial <44125644+sasial-dev@users.noreply.github.com>
Co-authored-by: Sasial <44125644+sasial-dev@users.noreply.github.com>
result types like that will not be happening in rewrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your PR doesn't fix the typings emitted in both lua and TS. They are "true"
and "false"
atm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This pr adds support for boolean literals in enums, a pattern that is useful for result types
ex: