bs-moment
bs-moment copied to clipboard
Moment.duration is not a function
Hey I ran into this error where the code compiles, but when I check the browser I get an error in the console saying that Moment.duration is not a function. Heres the code
MomentRe.Moment.subtract(
~duration=MomentRe.duration(7, `days),
MomentRe.momentNow()
)
Heres the error:
Turns out this is b/c moment 1.3.x exports the module differently. So you have to change the moment bindings to use default
:
[@bs.module "moment"] external momentNow : unit => t = "default";
I've gone ahead and rolled my own bindings and can confirm this is the way to fix it.
@kennetpostigo, for now, the expected version of moment
is "moment": "^2.20.1"
as specified in package.json
. You are using an old version. Do you think it is possible for you to upgrade?
If not, probably we need to figure out how to publish dual versioned bindings.
@Jimexist we have the same problem on my project and we have "moment": "2.22.2"
. I also created a fork of this and am using that at the moment.