Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Cannot annotate/export functions from manually typed submodule #469

Closed
chrischen opened this issue Oct 27, 2020 · 2 comments · Fixed by #470
Closed

Cannot annotate/export functions from manually typed submodule #469

chrischen opened this issue Oct 27, 2020 · 2 comments · Fixed by #470

Comments

@chrischen
Copy link

chrischen commented Oct 27, 2020

If manually specifying the interface for module, the @genType annotation does not work on functions, but works on types.

module Test: {
  [@genType]
  type t = pri string;
  [@genType]
  let make: t => string;
} = {
  type t = string;
  [@genType]
  let make = t => t ++ "...";
};

Generates

export type Test_t = string;

But the Test_make function is not generated.

If I get rid of the type interface:

module Test = {
  [@genType]
  type t = string;
  [@genType]
  let make = t => t ++ "...";
};

Then both types are generated.

export const Test_make: (t:string) => string = MessageBS.Test.make;
export type Test_t = string;

The docs say that if .rei files exist it will take the annotations from there. However I've tried annotating in the interface and in the implementation and no combination could get it to output. The workaround I am using is to define another module and include it in the module that I manually type with an interface.

module Test_Types = {
  /** I put shared types/functions here, but I can't use private types */
  [@genType]
  type t = string;
  [@genType]
  let make = t => t ++ "...";
};
module Test: {
  include (module type of Test_Types);
} = {
  include Test_Types;
};

Is this a bug or is there some other syntax for getting this to work?

@chrischen chrischen changed the title Cannot annotate and export from manually typed submodule Cannot annotate/export functions from manually typed submodule Oct 27, 2020
cristianoc added a commit that referenced this issue Oct 28, 2020
(e.g. `module M : { ... } = { ... }`).

Fixes #469
@cristianoc
Copy link
Collaborator

@chrischen thanks for the report!
Looks like the case of annotations in the signature of inner modules was in fact missing.
Handled here:
#470

See the example there.

cristianoc added a commit that referenced this issue Oct 29, 2020
(e.g. `module M : { ... } = { ... }`).

Fixes #469
@cristianoc
Copy link
Collaborator

Fix in release 3.38.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants