How To Extend Module And Use Same Namespace

Hello! I was wondering out I can override a namespace or what would be the idiomatic approach for extending a module. For instance, I want to add methods to the Promise module. I created a new file with the name Promise and tried to include Promise but it doesn’t seem to work.

// Promise.res
include Promise
let foo = ...
// App.res

That’s because Promise got inferred to be your own module. So you’re getting a cyclic reference error (right?)

Name your file Promise2 or something. Btw, generally speaking, we don’t recommend using include, nor wrapping and re-export. The story here isn’t as good as e.g. Swift’s.

1 Like

Are they sitting in the same package?
There is a chance that maybe your Promise does not have higher precedence against the other Promise module,

I don’t think so. The Promise module is a separate 3rd party installed library/namespace.

Hmm, I wouldn’t know how to debug that just yet.

Okedoke, thanks for the reply! I’ll plan on using another namespace then.