Instead of:
[@bs.module] external foo: string => string = "bar";
I propose:
[@bs.module] external bar as foo: string => string;
That "bar" in the first is super confusing for beginners. Not intuitive.
Good idea. That particular proposal would require a concrete syntax change in reason in addition to requiring a BuckleScript ppx change. The following would only require a BuckleScript ppx change.
let foo: string => string = [%require "bar"];
Maybe that's just as intuitive?
IMO, that last = is misleading, unfortunately. It looks like an assignment for the second string.
Update: Nevermind.
Per JustGate's tweet, another suggestion:
[@bs.module] external foo: string => string from "bar";
Essentially replacing the = at the end with a from
But you don’t have a similar response to this
“let x: string => string = something”
Thats just standard type annotations syntax.
I was actually thinking import foo: string => string from "bar"; Or maybe importJs foo: string => string from "bar"; Just make it as es6 as possible.
I do really like @jordwalke's syntax as well though, maybe even better 👍. It's not far off CommonJS syntax:
var foo = require('lodash');
Some options:
let foo: string => string = [%jsModule "bar"];
let foo: string => string = [%import "bar"];
let foo: string => string = [%require "bar"];
I think the ability to "multicursor" a JS file to a Reason file easily is important (naturally you'd have to write the type annotations)
Most helpful comment
Good idea. That particular proposal would require a concrete syntax change in reason in addition to requiring a BuckleScript ppx change. The following would only require a BuckleScript ppx change.
Maybe that's just as intuitive?