Skip to content

Deprecated decorator w/ let and pipes #8013

@CarlOlson

Description

@CarlOlson
  1. In my example the deprecated warning and migration will only happen for external functions. I'd expect this to also work with top-level let functions.
  2. The migration will not create pipes unless used by the deprecated code. Somehow allowing migrating to pipes would be very helpful for migrating old pipe-last code that has been formatted into direct function calls.
  3. The migrated code retains unnecessary underscores. This is again something prevalent in code manually migrated from the pipe-last to pipe-first operator.

Example tested on ReScript 12 RC3:

@deprecated({
  reason: "something",
  migrate: %insert.unlabelledArgument(1)->map2(%insert.unlabelledArgument(0)),
})
@val
external map: ('a => 'b, 'a) => 'b = "something"
/* let map = (fn, a) => fn(a) */

let map2 = (a, fn) => fn(a)

let test = a => {
  let fn = x => x * x
  map(fn, a) + a->map(fn, _)
}

Output:

let test = a => {
  let fn = x => x * x
  map2(a, fn) + a->map2(_, fn)
}

Desired output:

let test = a => {
  let fn = x => x * x
  a->map2(fn) + a->map2(fn)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions