rescript-association / reasonml.org

Deprecated in favor of rescript-lang.org
MIT License
125 stars 34 forks source link

Example for [%raw] does not work in .res file #235

Closed jdeisenberg closed 3 years ago

jdeisenberg commented 3 years ago

The example at https://reasonml.org/docs/reason-compiler/latest/embed-raw-javascript

let add = [%raw {|
  function(a, b) {
    console.log("hello from raw JavaScript!");
    return a + b
  }
|}];

Produces this error when compiled with BuckleScript 8.1.1 ( Using OCaml:4.06.1+BS )

File "/home/david/reasonlab/restest/src/Demo.res", line 2, characters 16-18:

1 │  let add = [%raw {|
2 │    function(a, b) {
3 │      console.log("hello from raw JavaScript!");
4 │      return a + b

consecutive expressions on a line must be separated by ';' or a newline
ryyppy commented 3 years ago

All examples are still in Reason syntax (recognizable by the extension name in the top right corner of each snippet):

image

We will make an announcement when all examples are also available in the new syntax as well (those will be marked as RES)