rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inner module signature annotated functions are broken

chrischen opened this issue · comments

module Test: {
  /* include (module type of Test_Types); */

	[@genType]
	let make: string => string; // Broken

	[@genType.as "make3"]
	let make2: string => string; // Broken
} = {
  /* include Test_Types; */

	let make = (_) => "test";
	let make2 = (_) => "test";
};

[@genType]
let makeTest = Test.make; // Works - also a viable workaround for those looking

This is the corresponding generated code:

export const Test_make: (_1:string) => string = MyModuleBS.Test.Test; // Broken - should be MyModuleBS.Test.make

export const Test_make3: (_1:string) => string = MyModuleBS.Test.Test; // Broken - should be MyModuleBS.Test.make2

export const makeTest: (_1:string) => string = MyModuleBS.makeTest; // Works

// I'm not sure why this also gets generated, but this becomes broken if we rename one of the functions to "make3"
export const Test: { make3: (_1:string) => string; make: (_1:string) => string } = MyModuleBS.Test

// probably should be = { make3: MyModuleBS.Test.make2, make: MyModuleBS.Test.make };

If I throw in a module include statement such as in the pattern for de-duplicating repeated types between interfaces and implementation, another weird behavior surfaces.


module Test_Types = {

  module TestSubModule = {
    type t = {
      content: string,
    };
  };
};
module Test: {
        include (module type of Test_Types);

	[@genType]
	let make: string => string; // Broken

	[@genType.as "make3"]
	let make2: string => string; // Broken
} = {
        include Test_Types;

	let make = (_) => "test";
	let make2 = (_) => "test";
};

Somehow "TestSubModule" works its way into the generated output despite never being used.

export const Test_make: (_1:string) => string = MyModuleBS.Test.TestSubModule;
export const Test_make3: (_1:string) => string = MyModuleBS.Test.TestSubModule;