Javascript 模块名称是绑定中使用的隐藏全局名称

Javascript 模块名称是绑定中使用的隐藏全局名称,javascript,binding,ffi,reason,bucklescript,Javascript,Binding,Ffi,Reason,Bucklescript,tl;dr:如何更改以下绑定以能够写入Intl.DateTimeFormat.make()而不是Intl.DateTimeFormat.make() 键入dateTimeFormat; [@bs.dering-abstract] 类型格式化选项={ [@bs.optional] 工作日:字符串, [@bs.optional] 日期:字符串, [@bs.optional] 月份:字符串, }; 模块Intl_{ 模块日期时间格式{ 模块Impl{ t型; }; [@bs.new]external

tl;dr:如何更改以下绑定以能够写入
Intl.DateTimeFormat.make()
而不是
Intl.DateTimeFormat.make()

键入dateTimeFormat;
[@bs.dering-abstract]
类型格式化选项={
[@bs.optional]
工作日:字符串,
[@bs.optional]
日期:字符串,
[@bs.optional]
月份:字符串,
};
模块Intl_{
模块日期时间格式{
模块Impl{
t型;
};
[@bs.new]external make:unit=>Impl.t=“Intl.DateTimeFormat”;
[@bs.send]外部格式:(Impl.t,Js.Date.t)=>string=“”;
};
}
Intl.DateTimeFormat.make()
->Intl.DateTimeFormat.format(Js.Date.make())
->Js.log;
问题

如果没有下划线,这将编译为:

var Impl = /* module */[];

var DateTimeFormat = /* module */[/* Impl */Impl];

var Intl = /* module */[/* DateTimeFormat */DateTimeFormat];

console.log(new Intl.DateTimeFormat().format(new Date()));

exports.Intl = Intl;

<> >问题是:代码> var ItL=…./> >阴影全局代码>国际代码> /代码>,从而中断<代码>新的ItL.DeTeMeFalm()/代码> ./P> < P>首先,我认为这是BuckleScript的一个bug。这个问题最近在年提出并在年得到部分解决,但它仍然保留了许多名称。你应该考虑把这件事提出来,或者在一个新的问题上。< /P> 同时,您可以通过完全限定名称来解决此问题
Intl
实际上不是一个全局对象,而是附加到全局对象,在网页的上下文中是
窗口
。但是,由于JavaScript将在本地环境中找不到全局对象时在全局对象上查找名称,因此它看起来非常像一个全局名称

因此,如果将
make
更改为:

[@bs.new] external make: unit => Impl.t = "window.Intl.DateTimeFormat";

它应该可以正常工作。

这不会很快成为问题。关于
bs-platform@next
它已经解决(根据您链接到的问题中的注释)。确认它在bucklescript v7.2.2中没有下划线的情况下工作