Modules generated by functors generate `unknown` typescript type.
painedpineapple opened this issue · comments
This seems related to #306
gentype: 3.21.0
bs-platform: 7.2.2
I have this functor:
module type MakePV = {
type t;
let tToJs: t => string;
let tFromJs: Js.String.t => option(t);
let name: string;
let toLabel: t => string;
};
module MakePV = (Config: MakePV) => {
include Sms.DeccoHelper.MakePV(Config);
let toLabel = Config.toLabel;
};
The Sms.DeccoHelper.MakePV
functor can be found here, https://github.com/SeaMonster-Studios/sms-reason/blob/master/packages/sms/src/utils/DeccoHelper.re
When I use the first functor above like this:
module Status =
DeccoHelper.MakePV({
[@bs.deriving jsConverter]
type t = [ | `Accepted | `Submitted | `Won];
let name = "Bid Status";
let toLabel = tToJs;
});
[@genType]
let status: module DeccoHelper.MakePV = (module Status);
The generated type for status in TypeScript is: export const status: unknown = BidBS.status;
I need the let bindings within the generated module to be available within TypeScript with the correct typings. Any idea what's causing this issue?
There's no special support for functors.
And something here I guess makes so that the type is not found, this would be why it gives unknown.
With one self-contained repro example of 3 or 4 lines, one could take a look at what kind of info is available in the typed tree, and see what's missing.
Here is a self-contained reproduction of the issue, https://github.com/thislogancall/repro-gentype-415
What'ss odd is that both the MakePV
module type within Demo.re as well as SeamonsterStudiosReason.DeccoHelper.MakePV
have the same type definition. I was originally breaking the gentype rule of not having a custom namespace for the SeamonsterStudiosReason
package removing that didn't resolve the issue.
Another thing I just realized is that [@genType.as]
doesn't work on types defined within that SeamonsterStudiosReason.DeccoHelper.MakePV
either. Seems related to the issue above. If it would be helpful to add an example of this to that repo as well just let me know.
@thislogancall it could be include
is the issue.
I can try if there is a self-contained example without any dependencies that can just be pasted in a few lines.