Doesn’t this forum need a “help” section for dumb questions like mine?
Just experimenting with javascript bindings, created a file
Chance.res
type t
@new @module external make: unit => t = "Chance"
@send external getBoolLikelihood: (t, {"likelihood": int}) => bool = "bool"
let getBool = (~likelihood=50, ()) => {
let c = make()
c->getBoolLikelihood({"likelihood": likelihood})
}
It works, now I want a resi file so only getBool is public (yes I’ve read elsewhere that rewriting the interface to a JS module is maybe annoying) but this is just for learning.
Mousing over getBool gives me
(~?likelihood: int, unit) => bool
So I assume this is the type signature for getBool (what else could it be?), so from this, I create
Chance.resi
let getBool: (~?likelihood: int, unit) => bool
Saving it removes the “?”, confused, I save without formatting
I get this baffling error
The implementation /Users/kevin/Development/rescript-stuff/template-one/src/lib/Chance.res
does not match the interface src/lib/chance.cmi:
Values do not match:
let getBool: (~?likelihood: int, unit) => bool
is not included in
let getBool: (~likelihood: int, unit) => bool
File "/Users/kevin/Development/rescript-stuff/template-one/src/lib/Chance.resi", line 2, characters 1-47:
Expected declaration
File "/Users/kevin/Development/rescript-stuff/template-one/src/lib/Chance.res", line 5, characters 5-12:
First thing that stands out is there is no src/lib/chance.cmi? Maybe its the “compiled” version of Chance.resi, which might be a fun fact but not really helpful.
I try again, letting the auto formatting remove the ?
does not match the interface src/lib/chance.cmi:
Values do not match:
let getBool: (~?likelihood: int, unit) => bool
is not included in
let getBool: (~likelihood: int, unit) => bool
File "/Users/kevin/Development/rescript-stuff/template-one/src/lib/Chance.resi", line 3, characters 1-46:
Expected declaration
File "/Users/kevin/Development/rescript-stuff/template-one/src/lib/Chance.res", line 5, characters 5-12:
Same exact error, even though I changed the code.