ReScript is a language and compiler toolchain for building performant, easy-to-maintain JavaScript and ReactJS applications. It is a strongly typed language with many interoperability features to integrate nicely in existing JavaScript codebases.
Questions tagged [rescript]
78 questions
0
votes
1 answer
How to access decode in rescript-json-combinators?
Trying to use decode from rescript-json-combinators library, it is mentionned that Decoders have been made abstract and they have to be run via Decode.decode
let targetValue: JsonCombinators.Json.Decode.decode
Trying to use this…

Fer iel
- 23
- 4
0
votes
1 answer
How to send the result of a pipline into a switch statement?
I want to send the result of a pipeline into a switch statement
let onWithOptions = (~key: string, eventName, options: options, decoder) =>
onCB(eventName, key, event => {
...
event |> Tea_json.Decoder.decodeEvent(decoder) |>
…

Fer iel
- 23
- 4
0
votes
0 answers
Belt.Map.String Is there a replacement for add() method?
Map.String does not work in ReScript so I am using Belt.Map.String instead but it doesn't have "add" method is there a replacement for it if not what can I use instead Belt.Map.String?
let getAllResponseHeadersAsDict = (x: t):…

Fer iel
- 23
- 4
0
votes
1 answer
How to represent method calls ReScript 9.1.2
ReScript 9.1.2 made the original @meth semantics inaccessible they said to use @send external instead to represent method calls
My questions are:
can @send external be inside a type?
and is this a correct way to use it knowing that it generates the…

Fer iel
- 23
- 4
0
votes
1 answer
Conversion from ocaml to rescript "Did you forget a `=>` here?" syntax error
Trying to convert this OCaml code to Rescript
let emptyEventHandler = ((((fun _ev -> ())
[@bs ]) : Web.Node.event_cb) : Web.Node.event_cb)
And that is what I have got after the conversion
let emptyEventHandler: Web.Node.event_cb = ((. _ev) => ():…

alice sky
- 3
- 1
0
votes
0 answers
Longident.flat error when trying to migrate a file from bucklescript to rescript
Trying to rescript bucklescript-tea and after using rescript convert -all
All the files converted except for 2 files that handle http stuff this error showed up
Fatal error: Longident.flat
Fatal error: exception Whole_compiler.Misc.Fatal_error
Any…

alice sky
- 3
- 1
0
votes
1 answer
Rescript retrieving a single character from a string as a char type
How do you get a char from a string. This returns a string
Js.String2.charAt("abc", 0) //=> returns "a" not 'a'
While this returns the character code (int)
String.get("abc", 0) //=> returns 97 not 'a'
The second one makes sense, if you look at…

akaphenom
- 6,728
- 10
- 59
- 109
0
votes
1 answer
Rescript open is not bringing functions into scope
How is open and module prefixing supposed to work in rescript and rescript-react. It doesn't appear to be adhering to the documentation. For example, I have a file reader module
FileReader.res
module FileReader = {
type fileReader
type file =…

akaphenom
- 6,728
- 10
- 59
- 109
0
votes
2 answers
How to define an abstract (opaque) interface for a polymorphic object type?
ReasonML
module type T = {
type t('a); // Does not work
type b; // Works
};
module A: T = {
type t('a) = {.. b: bool} as 'a;
type b = bool;
};
module B: T = {
type t('a) = {.. c: int} as 'a;
type b = int;
};
Ocaml
module type T = sig
…

Chris
- 988
- 3
- 18
- 30
0
votes
3 answers
How to do document.createElement in ReScript
ReScript seems to be a better way to write JS code, but I am not able to find what should be a simple single line of docs.
How do I call functions like document.createElement()?
I tried Js.document, Dom.document, by looking at this page:…

vinay-deshmukh
- 71
- 1
- 5
0
votes
1 answer
How to use a variant option to type function parameters in rescript?
I would like to do the following. But it seems I cannot type the function parameter with one of the variant option. What would be the proper way to achieve this in rescript?
Here is a playground
type subject = Math | History
type person =
…

JeromeBu
- 1,099
- 7
- 13
0
votes
1 answer
Accessing key from variant type in rescript
I am pretty new to rescript and trying to understand how things are working. In my situation I would like to access a key from a variant type like this.
type personType = Person({name: string, age: int})
let person = Person({
name: "Jane",
age:…

JeromeBu
- 1,099
- 7
- 13
0
votes
1 answer
Rescript Capitalised Component
From the Rescript Documentation, it is suggested spread can be used to enable passing a pre-existing list to a component. I am confused what exactly MyComponentis in Rescript as I cannot find a way to initialise a component, which can be done with a…

heiheihang
- 82
- 9
0
votes
0 answers
Is it possible to partially compile a Reason+React application?
I was thinking of making the dev experience as smooth as possible and the feedback loop as short as possible when compiling the Reason+React application. If I use
import React from 'react';
in a file, does that mean I have to bundle React with the…

Olle Härstedt
- 3,799
- 1
- 24
- 57
0
votes
1 answer
How to set a dynamic value as a Js.t key in ReScript?
Is there a way to set a dynamic value as a Js.t key in ReScript?

Siraj Kakeh
- 741
- 6
- 20