Open
Description
Importing code from another workspace often creates an error:
4 ┆ switch value {
5 ┆ | Some(arr) =>
6 ┆ module Array = await Belt.Array
7 ┆ Js.log(arr->Array.keepMap(x => x))
8 ┆ | None => ()
Unbound module type __Belt_Array__
- Here is the smallest example I've found: playgound
let fn = async value => {
switch value {
| Some(_) =>
module Array = await Belt.Array
()
| None => ()
}
}
- However, this does not error: playground
let fn = async value => {
module Array = await Belt.Array
switch value {
| Some(_) => ()
| None => ()
}
}
- Nor does this: playground
module type T = module type of Belt.Array
let fn = async value => {
switch value {
| Some(arr) =>
module Array: T = await Belt.Array
Js.log(arr->Array.keepMap(x => x))
| None => ()
}
}
But, (3) doesn't even produce an async import:
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';
let Belt_Array = require("rescript/lib/js/Belt_Array.js");
async function fn(value) {
if (value !== undefined) {
console.log(Belt_Array.keepMap(value, x => x));
return;
}
}
exports.fn = fn;
/* No side effect */
This has been tested on 11.1.4
and 12.0.0-alpha.5
, but the master branch has not been tested.
While importing Belt
or Js
asynchronously isn't desired, this error happens in my project in several useful locations.