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
4
votes
1 answer
ReScript, TypeScript: Cannot find module '@rescript/react/src/ReactDOM.gen' or its corresponding type declarations
I am gradually rewriting an application with React to TypeScript into ReScript.
I've already implemented few components in ReScript, but this is the first one, where I use ReactDOM.Style.t as property to my component.
Here is my minimized component…

Sergey Potapov
- 3,819
- 3
- 27
- 46
4
votes
1 answer
Optional arguments for higher-order functions
I try to write a binding for socket.io.
I am having trouble with a function (next() in my example code at the bottom), that either takes no argument or a error object (Js.Exn.raiseError("ERROR!")).
I can't find a way to define a function signature…

Octavia Kitsune
- 100
- 5
4
votes
4 answers
How to create an efficient group by function without mutation?
Is there a way to efficiently implement a group by function without mutation?
Naive implementation:
ReScript playground
JavaScript (see below)
var messages = [
{insertedAt: "2021-01-10"},
{insertedAt: "2021-01-12"},
{insertedAt:…

Raphael Rafatpanah
- 19,082
- 25
- 92
- 158
4
votes
1 answer
How do I generically traverse an array in ReScript?
Let's say I want to iterate over an array in a way that isn't well-supported by the Js/Belt standard library functions. For example, perhaps I need to examine pairs of elements at a time. With a list, this is straightforward to do in a recursive…

ezrast
- 258
- 4
- 7
3
votes
1 answer
How do I implement hash functions for arbitrary record types in ReScript?
I'm exploring ReScript for the first time. I want to build a hashmap using a record type as my key type, and I'm looking for guidance on implementing the hash function.
Here's my ReScript code:
type pointer = { id: string, table: string, spaceId:…

Just Jake
- 4,698
- 4
- 28
- 33
3
votes
0 answers
get Dates In Range in rescript and Daylight Saving Time
i have a calendar in my site which take a start date and end date and pass them into a function who calculates the dates between .
lets sat we have the start date Mon Mar 29 2021 03:00:00 GMT+0300 (Eastern European Summer Time) and the end date is…

Sura Oqaily
- 51
- 2
3
votes
1 answer
How to write custom ppx decorator to rescript?
I need to generate a value with a different type from my passed type. This is the first time I write on ocaml-like, and for example, in a familiar me haskell I would use Data.Generics.
How I have understood I need to use decorator and ppx. I wrote…

Gleb Patcia
- 365
- 2
- 15
3
votes
3 answers
How to Use SVG with React and ReasonML?
With create-react-app and JavaScript/TypeScript, I understand I'm able to "import" an SVG as noted below. How may I do so with ReasonML?
import { ReactComponent as Logo } from './logo.svg';
function App() {
return (
{/* Logo is an…

Ari
- 4,121
- 8
- 40
- 56
2
votes
0 answers
Does genType library supports generating types from typescript to rescript/reasonml?
I’m very new to reasonml/rescript community, What I know genType generates TS/flow types from rescript component while working in existing Typescript/flow codebase. Is there any other way around like I’m working on existing rescript codebase, does…

Vijay
- 398
- 5
- 14
2
votes
1 answer
Upload file with GraphQl+ReScript
Does anyone work with ApolloGraphQl + Rescript?
I struggle with uploading files.
How to implement apollo-upload-client ?
As I understand I should modify httpLink using the createUploadLink, and this function change content-type in my request.
let…

Ihar
- 31
- 2
2
votes
3 answers
How to use a JavaScript Material Design library in ReScript?
I am trying to use the material-ui library in a Rescript/React app. The code below will show a button:
@module("@material-ui/core/Button") external button: string = "default"
@react.component
let make = () => {

dilvan
- 2,109
- 2
- 20
- 32
2
votes
2 answers
How can I type a JS module method from Reason?
In an effort to refactor an existing JS based WebUI into a ReasonML, I'm trying to embed a some refactored code. Currently I'm doing this by embeddeding all the ReasonML code (so far) inside an iframe.
Space is extremely limited, so rather than…

Jamie
- 7,075
- 12
- 56
- 86
2
votes
4 answers
Are there use cases for single case variants in Ocaml?
I've been reading F# articles and they use single case variants to create distinct incompatible types. However in Ocaml I can use private module types or abstract types to create distinct types. Is it common in Ocaml to use single case variants like…

Chris
- 988
- 3
- 18
- 30
2
votes
1 answer
Suppressing Warning in Rescript: Js.Promise.make
When making a promise in Rescript:
let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2))
The ReScript compiler will give a warning on unused variable reject.
Is there a way to suppress this error?

heiheihang
- 82
- 9
2
votes
1 answer
How to make a type constructor private in rescript (except in current module)?
I would like to make a validation function taking a name and outputting a validName type. I don't want to be able to construct values of type ValidName outside the module without using the function validateName.
I am trying to make the ValidName…

JeromeBu
- 1,099
- 7
- 13