Skip to content

ReScript 9.1: weird error message if optional prop has no type annotation #5071

Closed
@cknitt

Description

@cknitt

Consider the following React component:

Test.resi:

@react.component
let make: (~s: string=?) => React.element

Test.res:

@react.component
let make = (~s=?) =>
  switch s {
  | Some(s) => React.string(s)
  | None => React.null
  }

This compiles fine in ReScript 9.0.

In ReScript 9.1, it gives me the following weird error message:

  The implementation /Users/christoph/projects/cca/xxx/src/navigation/Test.res
       does not match the interface src/navigation/test.cmi:
       Values do not match:
         external makeProps: (~?s: 's, ~?key: string, unit) => {"s": option<'s>} =
  "" "
      A!s@A#keyA@@@"
       is not included in
         external makeProps: (~?s: string, ~?key: string, unit) => {
  "s": option<string>,
} =
  "" "
      A!sAA#keyA@@@"
       File "/Users/christoph/projects/cca/xxx/src/navigation/Test.resi", line 1, characters 0-58:
         Expected declaration
       File "Test", line 1: Actual declaration

If I change Test.res to

@react.component
let make = (~s: option<string>=?) =>
  switch s {
  | Some(s) => React.string(s)
  | None => React.null
  }

it compiles fine with ReScript 9.1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions