String literal syntax

On rescript@9.1.4, this syntax works:

@val
external processOnExit: (
  @as("exit") _,
  int => unit
) => unit = "process.on"

processOnExit(exitCode =>
  Js.log("error code: " ++ Js.Int.toString(exitCode))
);

on the master branch, you get this error:

Screenshot 2022-01-04 at 17.54.47


  17 │ @val
  18 │ external processOnExit2: (
  19 │   @as("exit") _,
  20 │   int => unit
  21 │ ) => unit = "process.on"

  expect int, string literal or json literal {json|text here|json} 

FAILED: cannot make progress due to previous errors.
>>>> Finish compiling(exit: 1)

Is there another way to do it?

Thank you.

Why do you use Master?

1 Like

I am playing with the new @obj annotation that landed on master.

More generally, is the master branch of a repo expected to work? I kinda had that idea in my head.

Anyway, using it is testing it, isnt it? I could report issues that pop up, right?

Thanks for taking the time to answer.

I don’t think this is a general rule, and it’s likely not the case for rescript-compiler.

Sure, testing new features is always fun! But I think reporting issues for code that is not released even in beta is probably not very useful at this point yet.

That seems strange to me. I figure we would want to know about it if its in the master branch. Figured if some code was not ready to be consumed as beta it might be in some other branch. Clearly a bad assumption. Thanks for taking the time to explain.

You would not happen to know how to address that error though, would you? I tried a bunch of different ways and keep getting the error for string literal. Works for int with @as(3) for example.

Thanks again.

I guess this is totally up to the maintainers.

I’m pretty sure the new changes in master make " " behave like ` ` without interpolation, so in places where you could only use " " and not ` ` like in @as I guess you can’t use a string literal for now. Hongbo is likely working on some followup PR for that.

1 Like

Thank you, sir.

Also, I suppose the latest beta version to run would something like `10.0.0-nightly.1 which seems to have the @obj notation on in it.

Thanks again.

The master branch is mostly work-in-progress code, so it’s not the same as a proper beta release.

Good to know. Thanks.