Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/js/async.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pub async fn suspend[T, E : Error](
pub fn async_run(f : async () -> Unit) -> Unit = "%async.run"

///|
pub type Promise[_]
pub type Promise

///|
pub typealias AsyncOp = () -> Promise[Value]
pub typealias AsyncOp = () -> Promise

///|
extern "js" fn async_wrap_ffi(
Expand All @@ -25,18 +25,18 @@ pub async fn async_wrap(op : AsyncOp) -> Value! {
}

///|
extern "js" fn async_unwrap_ffi(op : async () -> Value!) -> Promise[Value] =
extern "js" fn async_unwrap_ffi(op : async () -> Value!) -> Promise =
#| (op) => new Promise((k, ke) => op(k, ke))

///|
pub fn async_unwrap[T](op : async () -> T!) -> Promise[Value] {
pub fn async_unwrap[T](op : async () -> T!) -> Promise {
async_unwrap_ffi(fn() { Value::cast_from(op!!()) })
}

///|
/// # Note
/// The return type is guaranteed to be a `Promise[Array[Value]]`, but we omit that detail for simplicity.
extern "js" fn Promise::all_ffi(ops : Array[Promise[Value]]) -> Promise[Value] = "(ops) => Promise.all(ops)"
/// The return type is guaranteed to be a `Promise` of an `Array`, but we omit that detail for simplicity.
extern "js" fn Promise::all_ffi(ops : Array[Promise]) -> Promise = "(ops) => Promise.all(ops)"

///|
async fn async_all_raw!(ops : Array[async () -> Value!]) -> Array[Value] {
Expand Down
8 changes: 4 additions & 4 deletions src/js/js.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ fn async_run(() -> Unit) -> Unit

fn async_test(() -> Unit!) -> Unit

fn async_unwrap[T](() -> T!) -> Promise[Value]
fn async_unwrap[T](() -> T!) -> Promise

fn async_wrap(() -> Promise[Value]) -> Value!
fn async_wrap(() -> Promise) -> Value!

let globalThis : Value

Expand Down Expand Up @@ -60,7 +60,7 @@ impl Optional {
undefined[T]() -> Self[T]
}

pub type Promise[_]
pub type Promise

type Symbol
impl Symbol {
Expand Down Expand Up @@ -204,7 +204,7 @@ impl Show for Value
impl @moonbitlang/core/json.FromJson for Value

// Type aliases
pub typealias AsyncOp = () -> Promise[Value]
pub typealias AsyncOp = () -> Promise

// Traits
pub(open) trait Cast {
Expand Down