-
Notifications
You must be signed in to change notification settings - Fork 38
Numeric poly var support #340
Comments
Sorry @bobzhang if I wonder, why will numeric variants be compiled to numbers ? |
@gaku-sei it is to provide good interop with JS API which expects enums or return enums. There is currently no easy way to do this without a conversion; and it is a pain point for production users. |
@bobzhang is there a reason we restrict this to non-float numbers? (I'll document this for posteriority) |
@IwanKaramazow the main use case is for passing and receiving enums. This is is the quote from some users:
Float can be a bit tricky, since Things could be done in the front-end:
In the future, we could support things like |
Thanks for the background, will implement. |
Makes actually, absolutely makes sense.
We use to interface with tailwind and concat the poly variant with some other string. In that case the new syntax happens to work, but I was concerned that some cases wouldn't work (hence the idea to differentiate |
@gaku-sei I think this still works since you mentioned concatenation.
|
Yeah kinda agree that maybe #"1" should be supported. Otherwise a bit inconsistent |
We could support #"1" syntactically, but it will be encoded as 1, so it may bring confusion instead of consistency. |
Oh, if #"1" is encoded as 1 then nevermind. Would rather have a good error message or formatted format to #1. But I was saying that it was confusing to not support #"1" as "1" |
I'm trying to create a tool to generate ReScript bindings from TypeScript type definitions (
It seems people often use Also, it kind of contradicts with the fact
|
The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions. |
Note we are planning to provide numeric poly var support so that
#"1"
is going to be compiled as 1 instead of "1"Ideally, we should allow user to write
#1
directly since it is compiled to 1 instead of "1"Some more context are provided here: rescript-lang/rescript#5026
For the formal rules it would be:
Also an extra overflow check is needed
The text was updated successfully, but these errors were encountered: