Skip to content

bs.deriving abstract: support functions #2776

@chenglou

Description

@chenglou
  54 │ [@bs.deriving abstract] type jsProps = {
  55 │   isDoNotDisturbEnabled: bool,
  56 │   onStatusChange: bool => unit,
  57 │ };
  58 │

  syntactic function type is not allowed when working with abstract bs.deriving, create a named type as work around

This error is thrown when we try to put a function signature in a record with bs.deriving abstract. This is out of interop currying concerns, but I think this constraint should be removed:

  • It's not going to be enforced consistently anyway, since lots of use-cases will be onStatusChange: Js.nullable(bool => unit), which doesn't error
  • Js objects (especially for UI) tend to contain a lot of callbacks. Aliasing them manually each time becomes very tedious.
  • We want to use this on bsb-native, so allowing functions make sense.

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