Skip to content

Optional fields for record only work with variables but not expressions #5733

Closed
@TimonFlick

Description

@TimonFlick

Using optional type for records with expression instead of variable does not work.

This is working:

let setDefaultOptions = (~newOptions: options) => {
  let weekStartOn = newOptions.weekStartOn->Option.map(Weekday.toInt)
  let options: options_ = {
    weekStartOn: ?weekStartOn,
  }
  setDefaultOptions_(~newOptions=options)
}

This is not working:

let setDefaultOptions = (~newOptions: options) => {
  let options: options_ = {
    weekStartOn: ?newOptions.weekStartOn->Option.map(Weekday.toInt),
  }
  setDefaultOptions_(~newOptions=options)
}

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master?

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