1
私はこれをコンパイルすることReasonMLを書くしようとしているが、JS:Reason(ReasonML)の[@ bs.this] BuckleScript属性はどのように使用しますか?
function main(example) {
example.foo = function() {
console.log(this)
}
}
ここに私の理由です:
let module Example = {
type t;
external set_foo_method : t => (t => unit [@bs.this]) => unit = "foo" [@@bs.set];
};
let main = fun example => Example.set_foo_method example (fun [@bs.this] x => {
Js.log(x);
});
私は2番目[@bs.this]
のために行と列の構文エラーを取得しています。
File "/Users/maxwellheiber/dev/rerect/src/demo.re", line 6, characters 62-64:
Error: 742: <SYNTAX ERROR>
私は@bs.thisのBuckleScriptドキュメントに従っています。
BuckleScriptを使用してReasonでOCamlと異なるthis
をバインドする構文はありますか?私はthis
を使用していますJSを生成する理由に[@bs.this]
BuckleScript属性を使用するにはどうすればよい
module Example = struct
type t
external set_foo_method : t -> (t -> unit [@bs.this]) -> unit = "foo" [@@bs.set]
end
let main example = Example.set_foo_method example (fun [@bs.this] x -> Js.log(x))
:BuckleScriptと、次のOCaml(ない理由は)正しいJSにエラーなしでコンパイル属性?
にコンパイルされますツールを推論するリンクいただきありがとうございます –