Migration from 7.x to 8.x


I’m currently migrating my app to bs-platform 8.2.0 and I notice a major change for me the removal of [@bs.as]. I think it’s should be added to the documentation.

There is a case where it’s needed like characters with dashes -. Or special name like type.

Is there a solution for these cases ?

Greetings :slight_smile:


Not sure in which cases you have been using [@bs.as] so far, but you can use it within record types now:

// Reason
type foo = {
  [@bs.as "other"]
  name: string,

let foo = {name: "test"};

Playground Link

Mostly for bindings props with some react libraries (like react-native-reanimated and props like type with slide-top or slide-bottom or react-native-vector-icons bindings.

Is this available only for bs-platform@8.3.x ?

The feature I mentioned above should be available with bs-platform@8.2 as well.

things like:

// Reason
[@bs.deriving jsConverter]
  type name = [
    | [@bs.as "glass"] `_glass
    | [@bs.as "music"] `_music
    | [@bs.as "search"] `_search
    | [@bs.as "envelope-o"] `_envelopeO
    | [@bs.as "heart"] `_heart

are still supported, but especially with the new poly variant representation the bs.deriving decorator should slowly go away, since poly vars without payload translate to strings:

// Reason
type name = [  `glass | `search];

// output: "glass"

// output: "search"

In ReScript we have special syntax for illegal identifier names that also work for poly var constructors, but we refrain from advertising this too much because ppl will definitely abuse this:

// ReScript
type name = [ #\"envelope-o"]

// output: "envelope-o"

Thanks for your explanation, indeed it’s the poly variant part that blocks me.
I’ll migrate to ReScript ASAP

I don’t think we removed bs.as , can u elaborate a little bit