Questions tagged [bucklescript]

BuckleScript was previously known as a compiler for compiling OCaml to efficient JavaScript code. It has now evolved into the ReScript language. Use the [rescript] tag instead.

BuckleScript was previously known as a back-end for which emits readable, modular and highly performant JavaScript.

On July 2020, BuckleScript (and some parts of the ReasonML syntax) evolved into the ReScript language platform. The term "BuckleScript" is therefore deprecated. Use the tag for BuckleScript specific questions instead.

Useful resources

Related tags

181 questions
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 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 best practice of iterating record keys and values in Reasonml?

I'm new to ReasonML, but I read through most of the official documents. I could go through the casual trial and errors for this, but since I need to write codes in ReasonML right now, I'd like to know the best practices of iterating keys and values…
Sanghyun Kim
  • 161
  • 1
  • 12
1
vote
2 answers

How to String matchAll in Reason?

I'm trying to replicate what I would do in javascript with matchAll() const names = [ ...withoutSlashes.matchAll(/(?<=Pos\. \d+ \- )(.*?)(?=","Importe)/g), ]; I see Reason has Js.String.match but I can't find the matchAll. I guess it's…
cuadraman
  • 14,964
  • 7
  • 27
  • 32
1
vote
1 answer

How to override/provide custom instances using bs-deriving

Using bs-deriving, I can derive e.g. show instances using [@deriving show]. However, it's not clear how I would use the same derivation but providing a custom show instance for a specific datatype. Example: [@deriving show] type bar =…
Felix
  • 8,385
  • 10
  • 40
  • 59
1
vote
1 answer

Using react native async storage getItem

React.useEffect(_ => { ReactNativeAsyncStorage.getItem("jwt") |> Js.Promise.then_(jwt => {Js.log(jwt)}); None; }); Error: This expression has type unit but an expression was expected of type Js.Promise.t('a) =…
1
vote
1 answer

How to iterate children obtained from ReactDOMRe.domElementToObj?

I'm trying to implement the FLIP animation technique. I have to access the getBoundingClientRect() of react's element children. let ref = React.useRef(Js.Nullable.null);
{Belt.List.map(items, item => { …
Jakub Zawiślak
  • 5,122
  • 2
  • 16
  • 21
1
vote
3 answers

Different result in OCaml and ReasonML

There is a case mapping two vectors into a single vector. I expected that the result of both ML should be same. Unfortunately, the result of ReasonML is different. Please help and comment how to fix it. OCaml List.map2 (fun x y -> x+y) [1;2;3]…
madeinQuant
  • 1,721
  • 1
  • 18
  • 29
1
vote
1 answer

Bucklescript is compiling utf8 ReasonML files into us-ascii

I'm using ReasonReact with bsb -init myapp -theme react-hooks. I run my project on MacOS Catalina. When building or starting my project, Bucklescript is compiling my utf8 *.re files into us-ascii. This results into bad encoded accentuated…
Neovea
  • 504
  • 3
  • 17
1
vote
1 answer

Only a single type was generated by @genType

After adding ReasonML to a React-Native typeScript codebase, I found that only a single type was generated by @genType, even though these two functions were transpiled by BuckleScript successfully. How to fix this…
madeinQuant
  • 1,721
  • 1
  • 18
  • 29
1
vote
1 answer

can one load reasonml es6 modules without a bundler

I am trying to use my VSCODDE liver server: https://github.com/ritwickdey/vscode-live-server for development without having to run a (parceljs would be my favorite, since it has hot loading, but it is having issues with reasonml). This almost works,…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
1
vote
1 answer

How to convert Js.Json.t to Js.t('a)?

I have encoded an object via bs-json and want to send it as a data via post using bs-axios. 33 │ let createTest = (p: Data.toBuyListItem) => inst->Instance.postData("/ test", p |> Data.encodeToBuyListItem); ... This has type: …
menfon
  • 1,587
  • 1
  • 11
  • 28
1
vote
1 answer

How to use Js.Option.map?

For this code: // val map : ('a -> 'b [@bs]) -> 'a option -> 'b option let optTest: Js.Option.t(int) = Js.Option.map(x => x, Js.Option.some(1)); I am getting following error: This expression should not be a function, the expected type is (.…
menfon
  • 1,587
  • 1
  • 11
  • 28