Skip to content

Pipe expression for optional record fields expects non-optional type #5627

Closed
@nkrkv

Description

@nkrkv

Experimenting with Playground. The following compiles with an error:

type t = {
  optValue?: int,
}

let x = Some(3)
let s1 = {optValue: ?(x->Belt.Option.map(a => a+1))} // <-- Type error
let s2 = {optValue: ?(Belt.Option.map(x, a => a+1))}
Type Errors
[E] Line 6, column 22:

This has type: option<int>
  Somewhere wanted: int

Screenshot:

image

So, the pipe expression highlighted has indeed type option<int> but the compiler wants a plain int for some reason.

Interesting, the same expression without the pipe compiles just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions