TheSpyder / rescript-mocha

Mocha bindings for ReScript
MIT License
0 stars 2 forks source link

Can't compile with ReScript v11 #4

Open dsiu opened 1 year ago

dsiu commented 1 year ago
$ rescript
rescript: [1/7] src/Internal-RescriptMocha.cmj
FAILED: src/Internal-RescriptMocha.cmj

  We've found a bug for you!
  /Users/dsiu/code/playground/rescript-mocha/src/Internal.res:105:78-127:6

  103 │ /* Constructs a function that can take the options that are normally s
      │ et with `this` in mocha */
  104 │ module With_Options = {
  105 │   let make: Fn_Type.internal_nullary<'result> => Fn_Type.fn<unit, 'res
      │ ult> = (
  106 │     fn,
    . │ ...
  126 │       done_callback()
  127 │     })
  128 │
  129 │   let make': Fn_Type.internal_callback => Fn_Type.fn<(~error: Js.Exn.t
      │ =?, unit) => unit, unit> = (

  This function expected 1 argument, but got 6

FAILED: cannot make progress due to previous errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
TheSpyder commented 1 year ago

Ah it doesn't work with uncurried mode. I'll have to add an extra setting to the bsconfig file.

dsiu commented 1 year ago

Adding “uncurried”: false in bsconfig.json works as expected.

But it also means top level projects that depends on rescript-mocha would need to do the same in their bsconfig.json as well.

Any tips on making Internal.res uncurried? I will study the code a bit more to see if I can come up with a fix.

(I am asking posting a question on ReScript forum to see if there is directive to enable curried on a per-file basis.

Thanks,

TheSpyder commented 1 year ago

I designed it with currying in mind so it might be a difficult conversion.

My other projects (most of which I took over maintenance on, didn't write myself) also require uncurried false so this doesn't surprise me.

dsiu commented 1 year ago

@TheSpyder : I took a look at your modern-api branch and removed some type annotation in the make* functions, and it seems to compile and work under uncurried mode in ReScript V11. The generated js code looks pretty clean.

Here is the commit: https://github.com/dsiu/rescript-mocha/commit/432cfd0154a208da819a4453b750f2c43d78f50e

I can make a pull request if needed.

TheSpyder commented 1 year ago

Oh I haven't thought about that branch in a long time (over a year, as it turns out). I knew I had a lot going on personally but didn't think it had been that long...

I just discovered a stack of uncommitted changes on my dev machine from June 2022 🤣

it looks like I was trying to migrate more towards uncurried code - this was all done before uncurried mode was confirmed - so I think it does make sense to update. I'll see if I can integrate your changes into that branch along with my uncommitted changes and make it a major release version. Thank you!

dsiu commented 1 year ago

Awesome. I can help too if needed.

TheSpyder commented 10 months ago

I haven't been actively using this project, nor has anyone in the community, so I forgot about this (I do remember reading your message at the time, but just found it again while clearing out my inbox).

I've pushed up those uncommitted changes to the modern-api branch. I don't know if they work, or what my intent was, but if you'd like to combine them with your branch and make a PR I'm happy to provide feedback.