rescript-lang / rescript-compiler

The compiler for ReScript.

Home Page:https://rescript-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extra parentheses in pipe operator cause code to fail compilation.

Mng12345 opened this issue · comments

commented
module Codec = {
  type encode<'v> = 'v => Js.Json.t
  type decode<'v> = Js.Json.t => result<'v, exn>
  type t<'v> = {
    encode: encode<'v>,
    decode: decode<'v>,
  }

  let make = (encode, decode) => {encode: encode, decode: decode}

  let encode = codec => codec.encode
  let encodeString = (codec, value) => codec->encode(value)->Js.Json.stringify

  let decode = codec => codec.decode
}

The code above can be compiled in Rescript v10, but can not be compiled in V11.0.1
v10 playground

v11.0.1 playground

This code snippest is from the rescript-jzon library, and it prevents me from upgradding to Rescript v11.

You can use https://github.com/ds300/patch-package or https://pnpm.io/cli/patch. Or prepare a PR to add V11 support for rescript-jzon. I know the author and can ping him for review. He's not using ReScript anymore, so probably he won't have time to update the package by himself. Also, you can migrate to rescript-schema 😈