BS 8.* cannot convert some .re to .res

Greetings everyone,
take the following Reason code from the old site documentation:

type tesla = {
  color: string,

let obj: tesla = {
  val red = "Red";
  pub color = red;

Js.log(obj#color) /* "Red" */

If you try to convert the code to ReScript using the playground you will get an error about a ppx not being implemented.

Is this a known issue? There are some more complex cases involving this and more that I am not sure how I should write using the new syntax, and unfortunately the formatter does not help :cry:.

I would sincerely really benefit from having in the object page ( – sorry, no more than 2 links…) of the documentation the same (or pretty similar) examples available in the old one, in order to have some sort of translating model in my mind. I think that this could help other people as well. :blush:

As far as I know there’s no object syntax in rescript, but you can have Js objects though if you want structural typing.

For “object syntax” you mean object-oriented? Because objects and records are handled differently like in Reason, so they “exists” in term compiler support.

If the point is about object-oriented syntax/approach, it is just because it still needs to be implemented, or it is a design decision? I hope for the former, not because I am a fan of OOP, but just because the language would be “less JS-y” from this point of view than before, and people would hack the problem around using raw JS syntax…

Ocaml OO is not supported in the new syntax.
You can use JavaScript objects:

type tesla = {"color": string}

let obj: tesla = {
  "color": "red",


playground example:

Sorry, maybe I have not been clear enough. I know that I can use the new object syntax – it’s the link at the documentation I posted initially.

Just to be more clear my questions are:

  1. As @Maxim wrote this simple example can be expressed with ReScript. Why the compiler is not able to transform the Reason syntax to Rescript? Is a known issue that is going to be supported in the future or is a wontfix?

As I already wrote, there are non-trivial (and pretty common) cases that I don’t know how to handle. The following example is from the same page of the documentation:

type tesla('a) = {
  drive: int => int
} as 'a;

let obj: tesla({. drive: int => int, doYouWant: unit => bool}) = {
  val hasEnvy = ref(false);
  pub drive = (speed) => {
  pub doYouWant = () => hasEnvy^;
  pri enableEnvy = (envy) => hasEnvy := envy
  1. Is this possible to use this on objects like is possible with Reason? If not now, will it be possible in the future?
  2. val, pub and pri have different meaning in Reason, is possible or it will be eventually possible to express the same thing? If not, will be able the compiler to perform some sort of conversion and, in that case, what behavior should I expect?
  3. Given that with Reason syntax it is possible to express open and closed objects, is it possible to do it with ReScript? If not, is something that it will be supported in the future?

I ask all these things because I would like to understand how the features of ReScript and Reason compare, what are the aims of ReScript in terms of being able to express intents previously allowed and what the tooling under the hood is supposed to help or not. Thanks for your patience.


No, ReScript’s syntax won’t support the full object system in the future. The current full object system is still supported (as per our commitment to backward compatibility) in the old syntaxes.

As maxim showed, we support object with quoted keys, which are a subset of the object system that compiles cleanly to JS and devoid of too many complex features of the full system.