Skip to content

ReScript 10 / records with optional fields #766

@cknitt

Description

@cknitt

ReScript 10 will support records with optional fields. This would allow us to simplify a lot of things/move them closer to how they are done in JS.

E.g., styles: Instead of

let styles = StyleSheet.create({
  open Style
  {
    "statusBar": style(
      ~flexDirection=#row,
      ~height=dp(22.),
      ~alignItems=#center,
      ~paddingLeft=dp(12.),
      (),
    ),
    "text": style(~color=NativeColors.white, ~marginLeft=dp(4.), ()),
  }
})

we could have

let styles = StyleSheet.create({
  open Style
  {
    "statusBar": style({
      flexDirection: #row,
      height: dp(22.),
      alignItems: #center,
      paddingLeft: dp(12.),
    }),
    "text": style({
      color: "white",
      marginLeft: dp(4.),
    }),
  }
})

Or for APIs taking some config object, like

Share.share(Share.content(~title="Title", ~url="https://example.com", ()))

we could have

Share.share({title: "Title", url: "https://example.com"})

@MoOx For me the question is, can these be breaking changes or should we try to remain compatible with the existing way where possible?

If we go for breaking changes, then we could also do #748 at the same time.

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