How do I turn a Js.Global.intervalId into an integer?
What’s your use case?
I’m creating a programming language.
I just want to use a primitive type.
It’s already a primitive type under the hood (a JS
number) so you don’t have to make any conversion.
If you want it to be recognized as an
int by the type system (but I still haven’t understood the use case), you can just use an identity conversion:
external intervalIdToInt: Js.Global.intervalId => int = "%identity"
intervalId values fit within the bounds of ReScript
int? It might not be type-safe to cast them. Generally for JS
number type it’s safer to use ReScript
That’s a valid concern, anyway it’s hard to answer without understanding how it’ll be used.
I ended up not converting it. Thanks anyway.