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
1
vote
1 answer
Compile Rescript with CLI -- no bsconfig.json
Is there a way to compile ReScript with just the CLI?
In other words, without the bsconfig.json?
Ideally, I would like to be able to just call the CLI and be able to compile into ES6, declare external dependencies, etc.

Nick
- 5,108
- 2
- 25
- 58
1
vote
1 answer
How to call a constructor function with new
I'm a new with ReScript. I try to use it with Telegraf. I imported telegraf:
@module("telegraf")
How I can call Telegraf constructor?
let tg = new telegraf.Telegraf("bot_token")

Mikita Melnikau
- 1,655
- 2
- 15
- 30
1
vote
1 answer
How to use List, Map, etc. from TypeScript
I have a combo ReScript and TypeScript project. I want to use gentype to expose TypeScript friendly objects. Gentype works for string, bool, records, and other basic objects without any hassles. How can I work with list and char and other…

JustinM
- 913
- 9
- 24
1
vote
1 answer
Curry.js error when exporting a rescript function with more than 1 parameter using genType
When exporting a function with more than 1 parameter (2 or more) it throws the following error, which basically says there is an issue with the way we import curry.js. I am attaching an example and package versions below.
Error:
Error…

Sergio G
- 101
- 1
- 6
1
vote
1 answer
How do I use modulus operator in Reason React?
When using the % operator in reason react I am left with an error "The value % can't be found". Is there another word for % used in Reason react?
Js.log(20 % 2)

Elissi
- 312
- 2
- 8
1
vote
1 answer
Installing several workspaced npm (yarn) packages from a git repository
I have two repositories. The first one contains is a monorepo with two packages:
- bsconfig.json
- package.json
- packages/
- transaction/
- package.json
- transaction.js
- reindexed/
- package.json
-…

manu
- 3,544
- 5
- 28
- 50
1
vote
1 answer
Rescript Record: Key as Array
In Rescript, one can define a Record in this format:
type record1 = {
a : String
}
but NOT:
type record2 = {
[a] : String
}
I am looking to write a record that compiles to JS like:
{
[Op.or]: [12,13]
}
The use case above comes from…

heiheihang
- 82
- 9
1
vote
1 answer
Jest - Cannot use import statement outside a module - using Rescript
I am trying to run unit tests in a React project generated using react-scripts, in which I added ReScript support.
When I run the tests, however, I encountered an error in the transpiled javascript code.
Details of the…

Massimiliano
- 615
- 4
- 15
1
vote
1 answer
Where is the documentation to write an event handler for input text box?
Originally I wanted to know:
How do I write a handler for this?
type state = string;
type action = | ChangeName(string)
let reducer = (_state, action) => switch action { | ChangeName(text) => text }
[@react.component]
let make = () => {
let…

Jamie
- 7,075
- 12
- 56
- 86
1
vote
1 answer
Rescript plugin rescript-vscode non working after a fresh install
New to rescript, i've done all steps specified in the getting started page and furthermore installed the visual studio code plugin but as I try to edit neither completion nor error highlighting works.
I've tried all steps on the plugin gif but if i…

zedryas
- 718
- 6
- 19
1
vote
1 answer
Comparing String in Rescript
After browsing through Rescript's API, it seems like there is no function that compares 2 strings that returns a boolean. The best option is localeCompare but it behaves somewhat different from the JS's ==. Why does localeCompare return a float…

heiheihang
- 82
- 9
1
vote
1 answer
How can one iterate/map over a Js.Json.t that is an array?
I'm trying to decode a JSON array that has the type Js.Json.t (not array(Js.Json.t) apparently). A call to Js.log(jsonList) reveals that it is an array, but I'm not certain how to map over the elements in the array to decode it.
So far, I've…

Jamie
- 7,075
- 12
- 56
- 86
1
vote
1 answer
How do I use an unwrapped polymorphic variant [union type] in a type parameter?
The Goal: Binding to the Service Worker Cache
I'm writing a binding to let me write Service Workers in ReScript. String URLs and Requests are sometimes used interchangeably.
Where possible, I'm avoiding noise in the JS output.
What I know about…

Eleanor Holley
- 691
- 1
- 7
- 27
1
vote
1 answer
Can I make Reason+React import react module from CDN?
Building a component with Reason and React always gives me an module import statement for "react", which cannot be found if React is included from a CDN. Is there a solution for this? I've tried to define window.react = React in index.html without…

Olle Härstedt
- 3,799
- 1
- 24
- 57
1
vote
2 answers
What is the typescript equivalent for ReasonML's option type?
In ReasonML option type is a variant which can either be Some('a) or None.
How would I model the same thing in typescript?

a-c-sreedhar-reddy
- 568
- 4
- 14