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

Using promises with setTimeout

I am new to Reason, currently trying to convert a personal project from js to reason. Mostly it has been easy so far apart from async stuff. I am not able to call my function recursively with delay. I have a function getPrice which returns a promise…
user17472
  • 139
  • 9
1
vote
1 answer

Get result of spawning child process in Node.js

How do I execute a child process and get the resulting exit code and output (stdout, stderr)? Something like let spawnResult = Node.Child_process.spawnSync("ls"); Js.log("Exit code: " ++ spawnResult.status); Js.log("Stdout: " ++…
Gudmundur Orn
  • 2,003
  • 2
  • 23
  • 31
1
vote
1 answer

Empty Type Declaration

What happens when one declares a type without binding it to anything: type a_type type b_type let a : a_type = (* ? *) I ran into this while reading BuckleScript FFI manual. The code for binding to a JS object looks like this: type t external…
Pandemonium
  • 7,724
  • 3
  • 32
  • 51
1
vote
1 answer

Creating a Reason package with a different namespace name than the NPM package

I started creating a native Reason unit test library, inspired by RSpec (I did one for F# previously) I wanted to call the library Respect, but since there was already an npm package named "respect", I named the npm library "re-respect". But my…
Pete
  • 12,206
  • 8
  • 54
  • 70
1
vote
1 answer

How to work with bucklescript requires and google functions

I'm trying to deploy functions created with bucklescript to google functions but the deploy won't run without this error : Did you list all required modules in the package.json dependencies? Detailed stack trace: Error: Cannot find module…
Parasithe
  • 25
  • 5
1
vote
1 answer

Can I pattern match on JS objects?

Given a function that accesses a property of a JavaScript object— let useFoo x => Js.log x##foo; useFoo {"foo": 10}; —is there a way to rewrite it to pattern match for the property? I'd hoped that something like this would work, but the syntax is…
ændrük
  • 782
  • 1
  • 8
  • 22
1
vote
1 answer

How do I use the [@bs.this] BuckleScript attribute in Reason (ReasonML)?

I'm trying to write ReasonML that compiles to this JS: function main(example) { example.foo = function() { console.log(this) } } Here's my Reason: let module Example = { type t; external set_foo_method : t => (t => unit…
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
0
votes
2 answers

Convert Json array to list of strings

I am reading this tutorial https://www.stackbuilders.com/blog/nonsense-getting-started-with-reason-and-reason-react/. One of the problems I am facing is that api.noopschallenge.com is now dead. I replaced the API call to this…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
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

Why can't I assign a 64bit integer to this field?

Is there a numeric suffix I should be using to assign a numerical constant value to an int64 type? A moderately editted version of the error is: We've found a bug for you! {file}.re:321:20-31 321 │ let (rsid:int64) = 180785985722; This has type:…
Jamie
  • 7,075
  • 12
  • 56
  • 86
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
0
votes
1 answer

How to convert a Js.Dict.t to Js.t in ReScript?

Is there a straight forward way to convert a Js.Dict.t like this one Js.Dict.fromArray([ ("bigKey", Js.Dict.fromArray([("smallKey", "value")])) ]) to Js.t like this one: { "bigKey": { "smallKey": "value" } }
Siraj Kakeh
  • 741
  • 6
  • 20
0
votes
1 answer

ReasonML way of returning various types from a single switch statement

I have predefined types that goes, type objA = {name: string} type objB = {age: int} and I want to have a variant type that goes, type test = | Atype(objA) | Btype(objB) and ultimately use pattern-matching to properly return the values of what…
Sanghyun Kim
  • 161
  • 1
  • 12
0
votes
1 answer

Disable react-jsx per file in a ReasonReact project

Is there a way to disable react-jsx transformation in some files of a ReasonReact project? I think the other way around is possible by not adding "reason": { "react-jsx": 3 } to bsconfig.json and by adding @@bs.config({jsx: 3}) to the top of the…
tsnobip
  • 289
  • 2
  • 8