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

Cannot annotate/export functions from manually typed submodule #469

Description

@chrischen

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions