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
0
votes
1 answer

Normalizr for ReasonML

I know ReasonML is a new language so tooling will be a bit behind. But I was wondering if there was a Bucklescript or ReasonML tool that acts as a Normalizr for data for reason-react. I know I can just make bindings and put them into Normalizr…
GTDev
  • 5,488
  • 9
  • 49
  • 84
0
votes
1 answer

Resolving query type with promise in bucklescript

I've got this query im trying to test with with the reason graphql_ppx library. code gist This is a screenshot of the editor type annotations: Using the @mhallin/graphql_ppx library, i've got the following query set up: module FilmQuery =…
armand
  • 693
  • 9
  • 29
0
votes
2 answers

unexpected output when pattern matching exception on a promise

I have the following piece of code: let test = Js.Promise.resolve("Hello") |> Js.Promise.then_(_obj => raise(Not_found)); let ker = switch test { | exception Not_found => Js.log("not found") | _ => Js.log("found") }; The…
Sibi
  • 47,472
  • 16
  • 95
  • 163
0
votes
1 answer

Its possible use List.fold_left to returns a Js.Obj?

I'm trying to do this in ReasonML without success. The problem is that I don't know the object keys. const items = { foo: () => 'ok', bar: () => 'ok2' }; const result = Object.keys(items).reduce((acc, key) => ({ ...acc, [key]:…
norvana
  • 45
  • 3
0
votes
1 answer

Type error in render after Promise

I'm trying to render a component with reason-react after I get data from fetch but I receive a type error. This is my code: GetData.re: let get = () => Js.Promise.( Fetch.fetch("localhost:8000/data.json") |> then_(Fetch.Response.json) |>…
SHI1485
  • 121
  • 1
  • 5
0
votes
1 answer

Understanding ReasonML/Bucklescript Externals

Just trying to generally understand what is going on here. Does this make sense to explain ReasonApolloTypes.gql as an example of using Externals. This is the bs.module code [@bs.module] external gql : ReasonApolloTypes.gql =…
armand
  • 693
  • 9
  • 29
0
votes
0 answers

ReasonML on VSCode - "Go to Definition" from inside *.ml library file doesn't work

I'm trying out ReasonML on VSCode. But have a little problem with "Go to Definition" feature. From a SomeFile.re I can right click -> "Go to Definition" on a standard library function (in this case Format.printf(...)) and it will jump to the…
hendysg
  • 136
  • 1
  • 5
0
votes
1 answer

Making ReasonML/Bucklescript output ES5 compatible code

While using ReasonML and Bucklescript, is it possible to configure Bucklescript so it won't generate export statements? I'd prefer if the generated code could be used as is in a browser, that is, being ES5 (or ES6) compatible. Edit: OK, while trying…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
0
votes
1 answer

Using a method on a custom named (IE named at runtime) property within Bucklescript

So, I'm trying to program an AI for the game Screeps, whose docs are found here. I'm trying to write my AI in OCaml, which I'm then compiling to Javascript via Bucklescript, whose docs are found here. Anywho, within Screeps' API is the method…
lacoperon
  • 3
  • 6
0
votes
1 answer

How to bind a whole module as a function?

I'm playing with reason, and I wanted to try to do the FFI for debug in order to learn. I have this code module Instance = { type t; external t : t = "" [@@bs.module]; }; module Debug = { type t; external createDebug : string => Instance.t…
ThomasThiebaud
  • 11,331
  • 6
  • 54
  • 77
-1
votes
1 answer

How can I convert JavaScript values to a variant in reasonml?

There are three values in JavaScript: Result.granted Result.denied Result.neverAskAgain How can they be converted to a variant? type result = | Granted | Denied | NeverAskAgain;
-1
votes
1 answer

How can we alias props when using the Hooks API?

Previously, I was using [@bs.as "in"] like so. [@bs.deriving abstract] type cssTransitionProps = { [@bs.as "in"] _in: bool, timeout: int, classNames: string, }; How can I do something similar here? module CSSTransition = { [@bs.module…
Raphael Rafatpanah
  • 19,082
  • 25
  • 92
  • 158
-1
votes
2 answers

How do I pass Variants as props to React Components in ReasonML?

I have tried the following approach to be able to send variants as props. type ipAddr = | IPV4 | IPV8; [@react.component] let make = () => { let appData = Data.tileData;
Deadfish
  • 2,047
  • 16
  • 17
-1
votes
1 answer

Managing a form with a lot of fields

I'm writing a form in ReasonReact. I used reducerComponent and a record as state. Let's say I have something like this: type state = { field1: string, field2: int, }; type action = | SetField1(string) | SetField2(int); let component =…
user3139560
  • 19
  • 1
  • 3
-1
votes
1 answer

Type error when processing graphql result

I just started playing with reasonML and graphql and have built a simple react component that retrieves data from a world cup API. My code is below: [@bs.module] external gql: ReasonApolloTypes.gql = "graphql-tag"; module GetMatches = [%graphql …
jwesonga
  • 4,249
  • 16
  • 56
  • 83
1 2 3
12
13