Skip to content

@this with async keyword #7681

@nojaf

Description

@nojaf

I'm struggling to combine @this with an async keyword to return a promise:

type pluginContext
type changeEvent

type p = {
  watch:  @this (pluginContext, string, changeEvent) => promise<unit>
}

let p1 = {
   watch: @this async (pc, name, ev) => {
    ()
  } 
}
Type Errors
[E] Line 9, column 22:
This has type:
    Js_OO.Callback.arity3<(pluginContext, string, changeEvent) => unit>
  But the record field watch is expected to have type:
    Js_OO.Callback.arity3<(pluginContext, string, changeEvent) => promise<unit>>
  
  The incompatible parts:
    unit vs promise<unit>

Playground

My syntax could be off, but I wonder if we support this.
@cristianoc do you have any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions