From cec3b4b3b50be54e1caa78326bcd2ff23aa2908d Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 6 Apr 2023 03:10:58 +0200 Subject: [PATCH 1/7] WIP: Demonstrate @genType issue with module aliasesgi See https://github.com/rescript-lang/rescript-compiler/issues/6112 --- .../typescript-react-example/src/MyModule.bs.js | 11 +++++++++++ .../typescript-react-example/src/MyModule.gen.tsx | 12 ++++++++++++ .../typescript-react-example/src/MyModule.res | 5 +++++ .../typescript-react-example/src/Usage.bs.js | 13 +++++++++++++ .../typescript-react-example/src/Usage.gen.tsx | 11 +++++++++++ .../typescript-react-example/src/Usage.res | 5 +++++ .../typescript-react-example/src/Wrapper.bs.js | 9 +++++++++ .../typescript-react-example/src/Wrapper.res | 1 + 8 files changed, 67 insertions(+) create mode 100644 jscomp/gentype_tests/typescript-react-example/src/MyModule.bs.js create mode 100644 jscomp/gentype_tests/typescript-react-example/src/MyModule.gen.tsx create mode 100644 jscomp/gentype_tests/typescript-react-example/src/MyModule.res create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Usage.res create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.res diff --git a/jscomp/gentype_tests/typescript-react-example/src/MyModule.bs.js b/jscomp/gentype_tests/typescript-react-example/src/MyModule.bs.js new file mode 100644 index 0000000000..3377033068 --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/MyModule.bs.js @@ -0,0 +1,11 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +function add(a, b) { + return a + b | 0; +} + +export { + add , +} +/* No side effect */ diff --git a/jscomp/gentype_tests/typescript-react-example/src/MyModule.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/MyModule.gen.tsx new file mode 100644 index 0000000000..e9acb394ff --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/MyModule.gen.tsx @@ -0,0 +1,12 @@ +/* TypeScript file generated from MyModule.res by genType. */ +/* eslint-disable import/first */ + + +// @ts-ignore: Implicit any on import +import * as MyModuleBS__Es6Import from './MyModule.bs'; +const MyModuleBS: any = MyModuleBS__Es6Import; + +// tslint:disable-next-line:interface-over-type-literal +export type t = number; + +export const add: (a:t, b:t) => t = MyModuleBS.add; diff --git a/jscomp/gentype_tests/typescript-react-example/src/MyModule.res b/jscomp/gentype_tests/typescript-react-example/src/MyModule.res new file mode 100644 index 0000000000..07d4f772c0 --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/MyModule.res @@ -0,0 +1,5 @@ +@genType +type t = int + +@genType +let add = (a: t, b: t): t => a + b diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js new file mode 100644 index 0000000000..04b9d76c21 --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as MyModule from "./MyModule.bs.js"; + +var b = MyModule.add(5, 3); + +var a = 5; + +export { + a , + b , +} +/* b Not a pure module */ diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx new file mode 100644 index 0000000000..383e5d732c --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx @@ -0,0 +1,11 @@ +/* TypeScript file generated from Usage.res by genType. */ +/* eslint-disable import/first */ + + +// @ts-ignore: Implicit any on import +import * as UsageBS__Es6Import from './Usage.bs'; +const UsageBS: any = UsageBS__Es6Import; + +import type {MyModuleAlias_t as Wrapper_MyModuleAlias_t} from './Wrapper.gen'; + +export const b: Wrapper_MyModuleAlias_t = UsageBS.b; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.res b/jscomp/gentype_tests/typescript-react-example/src/Usage.res new file mode 100644 index 0000000000..4d0e891e0a --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.res @@ -0,0 +1,5 @@ +open Wrapper + +let a = 5 +@genType +let b = MyModuleAlias.add(a, 3) diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js new file mode 100644 index 0000000000..29f77ba8c5 --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +var MyModuleAlias; + +export { + MyModuleAlias , +} +/* No side effect */ diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res new file mode 100644 index 0000000000..5b2290225b --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res @@ -0,0 +1 @@ +module MyModuleAlias = MyModule From 8685e2f3a45407a43486d25b4c7e2a30e5f3637c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 8 Apr 2023 04:22:06 +0200 Subject: [PATCH 2/7] add the option to use the `@genType` annotation at the module level --- CHANGELOG.md | 1 + jscomp/gentype/Annotation.ml | 11 +++++- jscomp/gentype/GenTypeConfig.ml | 4 ++ jscomp/gentype/TranslateSignature.ml | 3 +- jscomp/gentype/TranslateSignatureFromTypes.ml | 3 +- jscomp/gentype/TranslateStructure.ml | 38 ++++++++++--------- jscomp/gentype/TranslateTypeDeclarations.ml | 2 +- .../typescript-react-example/src/Hooks.res | 3 +- .../typescript-react-example/src/JSXV4.res | 6 ++- .../typescript-react-example/src/Usage.bs.js | 5 ++- .../src/Wrapper.bs.js | 3 +- .../src/Wrapper.gen.tsx | 14 +++++++ .../typescript-react-example/src/Wrapper.res | 3 +- 13 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d60dabe66..b470b74b5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Use best effort to determine the config when formatting a file. https://github.com/rescript-lang/rescript-compiler/pull/5968 https://github.com/rescript-lang/rescript-compiler/pull/6080 https://github.com/rescript-lang/rescript-compiler/pull/6086 https://github.com/rescript-lang/rescript-compiler/pull/6087 - Customization of runtime representation of variants. This is work in progress. E.g. some restrictions on the input. See comments of the form "TODO: put restriction on the variant definitions allowed, to make sure this never happens". https://github.com/rescript-lang/rescript-compiler/pull/6095 - Introduce untagged variants https://github.com/rescript-lang/rescript-compiler/pull/6103 +- GenType: add the option to use the `@genType` annotation at the module level, meaning that all the items in the module should be exported. https://github.com/rescript-lang/rescript-compiler/pull/6113 #### :boom: Breaking Change diff --git a/jscomp/gentype/Annotation.ml b/jscomp/gentype/Annotation.ml index 6cce32d4f4..ad3eca5b52 100644 --- a/jscomp/gentype/Annotation.ml +++ b/jscomp/gentype/Annotation.ml @@ -154,7 +154,9 @@ let getDocString attributes = let hasAttribute checkText (attributes : Typedtree.attributes) = getAttributePayload checkText attributes <> None -let fromAttributes ~loc (attributes : Typedtree.attributes) = +let fromAttributes ~(config : GenTypeConfig.t) ~loc + (attributes : Typedtree.attributes) = + let default = if config.everything then GenType else NoGenType in if hasAttribute tagIsGenTypeOpaque attributes then GenTypeOpaque else if hasAttribute (fun s -> tagIsGenType s || tagIsGenTypeAs s) attributes then ( @@ -166,7 +168,7 @@ let fromAttributes ~loc (attributes : Typedtree.attributes) = Format.fprintf ppf "Annotation payload is ignored") | _ -> ()); GenType) - else NoGenType + else default let rec moduleTypeCheckAnnotation ~checkAnnotation ({mty_desc} : Typedtree.module_type) = @@ -289,3 +291,8 @@ let importFromString importString : import = in let importPath = ImportPath.fromStringUnsafe importString in {name; importPath} + +let updateConfigForModule ~(config : GenTypeConfig.t) attributes = + if attributes |> hasAttribute tagIsGenType then + {config with everything = true} + else config diff --git a/jscomp/gentype/GenTypeConfig.ml b/jscomp/gentype/GenTypeConfig.ml index 6e63c7a344..aa8e2af049 100644 --- a/jscomp/gentype/GenTypeConfig.ml +++ b/jscomp/gentype/GenTypeConfig.ml @@ -9,6 +9,7 @@ type t = { mutable emitImportCurry: bool; mutable emitImportReact: bool; mutable emitTypePropDone: bool; + mutable everything: bool; exportInterfaces: bool; generatedFileExtension: string option; module_: module_; @@ -27,6 +28,7 @@ let default = emitImportCurry = false; emitImportReact = false; emitTypePropDone = false; + everything = false; exportInterfaces = false; generatedFileExtension = None; module_ = ES6; @@ -190,6 +192,7 @@ let readConfig ~getBsConfigFile ~namespace = | Some sourceItem -> Some sourceItem | _ -> default.sources in + let everything = false in { bsbProjectRoot; bsDependencies; @@ -197,6 +200,7 @@ let readConfig ~getBsConfigFile ~namespace = emitImportCurry = false; emitImportReact = false; emitTypePropDone = false; + everything; exportInterfaces; generatedFileExtension; module_; diff --git a/jscomp/gentype/TranslateSignature.ml b/jscomp/gentype/TranslateSignature.ml index 334b46a790..932da78028 100644 --- a/jscomp/gentype/TranslateSignature.ml +++ b/jscomp/gentype/TranslateSignature.ml @@ -9,7 +9,7 @@ let translateSignatureValue ~config ~outputFileRelative ~resolver ~typeEnv Log_.item "Translate Signature Value %s\n" (val_id |> Ident.name); let typeExpr = val_desc.ctyp_type in let addAnnotationsToFunction type_ = type_ in - match (val_id, val_attributes |> Annotation.fromAttributes ~loc:val_loc) with + match (val_id, val_attributes |> Annotation.fromAttributes ~config ~loc:val_loc) with | id, GenType -> id |> Ident.name |> Translation.translateValue ~attributes:val_attributes ~config @@ -118,6 +118,7 @@ and translateSignatureItem ~config ~outputFileRelative ~resolver ~typeEnv let moduleItem = Runtime.newModuleItem ~name:(moduleTypeDeclaration.mtd_id |> Ident.name) in + let config = moduleTypeDeclaration.mtd_attributes |> Annotation.updateConfigForModule ~config in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; moduleTypeDeclaration |> translateModuleTypeDeclaration ~config ~outputFileRelative ~resolver diff --git a/jscomp/gentype/TranslateSignatureFromTypes.ml b/jscomp/gentype/TranslateSignatureFromTypes.ml index 79a32969dc..9e798a91b4 100644 --- a/jscomp/gentype/TranslateSignatureFromTypes.ml +++ b/jscomp/gentype/TranslateSignatureFromTypes.ml @@ -64,6 +64,7 @@ and translateSignatureItemFromTypes ~config ~outputFileRelative ~resolver } | Types.Sig_module (id, moduleDeclaration, _) -> let moduleItem = Runtime.newModuleItem ~name:(id |> Ident.name) in + let config = moduleDeclaration.md_attributes |> Annotation.updateConfigForModule ~config in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; moduleDeclaration |> translateModuleDeclarationFromTypes ~config ~outputFileRelative ~resolver @@ -73,7 +74,7 @@ and translateSignatureItemFromTypes ~config ~outputFileRelative ~resolver if !Debug.translation then Log_.item "Translate Sig Value %s\n" name; let moduleItem = Runtime.newModuleItem ~name in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; - if val_attributes |> Annotation.fromAttributes ~loc:val_loc = GenType then + if val_attributes |> Annotation.fromAttributes ~config ~loc:val_loc = GenType then name |> Translation.translateValue ~attributes:val_attributes ~config ~docString:(Annotation.getDocString val_attributes) diff --git a/jscomp/gentype/TranslateStructure.ml b/jscomp/gentype/TranslateStructure.ml index b7ec562c76..29ab23aba4 100644 --- a/jscomp/gentype/TranslateStructure.ml +++ b/jscomp/gentype/TranslateStructure.ml @@ -94,7 +94,7 @@ let translateValueBinding ~config ~outputFileRelative ~resolver ~typeEnv if !Debug.translation then Log_.item "Translate Value Binding %s\n" name; let moduleItem = Runtime.newModuleItem ~name in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; - if vb_attributes |> Annotation.fromAttributes ~loc:vb_pat.pat_loc = GenType + if vb_attributes |> Annotation.fromAttributes ~config ~loc:vb_pat.pat_loc = GenType then id |> Ident.name |> Translation.translateValue ~attributes:vb_attributes ~config @@ -137,12 +137,14 @@ let rec removeDuplicateValueBindings (boundInRest, structureItem :: filteredRest) | [] -> (StringSet.empty, []) -let rec translateModuleBinding ~config ~outputFileRelative ~resolver ~typeEnv +let rec translateModuleBinding ~(config : GenTypeConfig.t) ~outputFileRelative + ~resolver ~typeEnv ({mb_id; mb_expr; mb_attributes} : Typedtree.module_binding) : Translation.t = let name = mb_id |> Ident.name in if !Debug.translation then Log_.item "Translate Module Binding %s\n" name; let moduleItem = Runtime.newModuleItem ~name in + let config = mb_attributes |> Annotation.updateConfigForModule ~config in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; let typeEnv = typeEnv |> TypeEnv.newModule ~name in match mb_expr.mod_desc with @@ -240,9 +242,9 @@ let rec translateModuleBinding ~config ~outputFileRelative ~resolver ~typeEnv Translation.empty and translateStructureItem ~config ~outputFileRelative ~resolver ~typeEnv - structItem : Translation.t = + (structItem : Typedtree.structure_item) : Translation.t = match structItem with - | {Typedtree.str_desc = Typedtree.Tstr_type (recFlag, typeDeclarations)} -> + | {str_desc = Tstr_type (recFlag, typeDeclarations)} -> { importTypes = []; codeItems = []; @@ -252,30 +254,30 @@ and translateStructureItem ~config ~outputFileRelative ~resolver ~typeEnv ~outputFileRelative ~recursive:(recFlag = Recursive) ~resolver ~typeEnv; } - | {Typedtree.str_desc = Tstr_value (_loc, valueBindings)} -> + | {str_desc = Tstr_value (_loc, valueBindings)} -> valueBindings |> List.map (translateValueBinding ~config ~outputFileRelative ~resolver ~typeEnv) |> Translation.combine - | {Typedtree.str_desc = Tstr_primitive valueDescription} -> + | {str_desc = Tstr_primitive valueDescription} -> (* external declaration *) valueDescription |> Translation.translatePrimitive ~config ~outputFileRelative ~resolver ~typeEnv - | {Typedtree.str_desc = Tstr_module moduleBinding} -> + | {str_desc = Tstr_module moduleBinding} -> moduleBinding |> translateModuleBinding ~config ~outputFileRelative ~resolver ~typeEnv - | {Typedtree.str_desc = Tstr_modtype moduleTypeDeclaration} -> + | {str_desc = Tstr_modtype moduleTypeDeclaration} -> moduleTypeDeclaration |> TranslateSignature.translateModuleTypeDeclaration ~config ~outputFileRelative ~resolver ~typeEnv - | {Typedtree.str_desc = Tstr_recmodule moduleBindings} -> + | {str_desc = Tstr_recmodule moduleBindings} -> moduleBindings |> List.map (translateModuleBinding ~config ~outputFileRelative ~resolver ~typeEnv) |> Translation.combine | { - Typedtree.str_desc = + str_desc = (* Bucklescript's encoding of bs.module: include with constraint. *) Tstr_include { @@ -301,30 +303,30 @@ and translateStructureItem ~config ~outputFileRelative ~resolver ~typeEnv } -> structItem1 |> translateStructureItem ~config ~outputFileRelative ~resolver ~typeEnv - | {Typedtree.str_desc = Tstr_include {incl_type = signature}} -> + | {str_desc = Tstr_include {incl_type = signature}} -> signature |> TranslateSignatureFromTypes.translateSignatureFromTypes ~config ~outputFileRelative ~resolver ~typeEnv |> Translation.combine - | {Typedtree.str_desc = Tstr_eval _} -> + | {str_desc = Tstr_eval _} -> logNotImplemented ("Tstr_eval " ^ __LOC__); Translation.empty - | {Typedtree.str_desc = Tstr_typext _} -> + | {str_desc = Tstr_typext _} -> logNotImplemented ("Tstr_typext " ^ __LOC__); Translation.empty - | {Typedtree.str_desc = Tstr_exception _} -> + | {str_desc = Tstr_exception _} -> logNotImplemented ("Tstr_exception " ^ __LOC__); Translation.empty - | {Typedtree.str_desc = Tstr_open _} -> + | {str_desc = Tstr_open _} -> logNotImplemented ("Tstr_open " ^ __LOC__); Translation.empty - | {Typedtree.str_desc = Tstr_class _} -> + | {str_desc = Tstr_class _} -> logNotImplemented ("Tstr_class " ^ __LOC__); Translation.empty - | {Typedtree.str_desc = Tstr_class_type _} -> + | {str_desc = Tstr_class_type _} -> logNotImplemented ("Tstr_class_type " ^ __LOC__); Translation.empty - | {Typedtree.str_desc = Tstr_attribute _} -> + | {str_desc = Tstr_attribute _} -> logNotImplemented ("Tstr_attribute " ^ __LOC__); Translation.empty diff --git a/jscomp/gentype/TranslateTypeDeclarations.ml b/jscomp/gentype/TranslateTypeDeclarations.ml index 45f7365d87..b011e9d1cf 100644 --- a/jscomp/gentype/TranslateTypeDeclarations.ml +++ b/jscomp/gentype/TranslateTypeDeclarations.ml @@ -50,7 +50,7 @@ let renameRecordField ~attributes ~name = let traslateDeclarationKind ~config ~loc ~outputFileRelative ~resolver ~typeAttributes ~typeEnv ~typeName ~typeVars declarationKind : CodeItem.typeDeclaration list = - let annotation = typeAttributes |> Annotation.fromAttributes ~loc in + let annotation = typeAttributes |> Annotation.fromAttributes ~config ~loc in let opaque = match annotation = Annotation.GenTypeOpaque with | true -> Some true diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res index 13d2f53766..9a46abfc8a 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res @@ -25,7 +25,8 @@ let make = (~vehicle) => { } -@genType let default = make +@genType +let default = make module Another = { @genType @react.component diff --git a/jscomp/gentype_tests/typescript-react-example/src/JSXV4.res b/jscomp/gentype_tests/typescript-react-example/src/JSXV4.res index 97c7584aee..fc4ed11c96 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/JSXV4.res +++ b/jscomp/gentype_tests/typescript-react-example/src/JSXV4.res @@ -1,14 +1,16 @@ @@jsxConfig({version: 4}) +@genType module CompV4 = { - @genType @react.component + @react.component let make = (~x, ~y) => React.string(x ++ y) } @@jsxConfig({version: 3}) +@genType module CompV3 = { - @genType @react.component + @react.component let make = (~x, ~y) => React.string(x ++ y) } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js index 04b9d76c21..b64bd4a019 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js @@ -1,8 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as MyModule from "./MyModule.bs.js"; +import * as Curry from "rescript/lib/es6/curry.js"; +import * as Wrapper from "./Wrapper.bs.js"; -var b = MyModule.add(5, 3); +var b = Curry._2(Wrapper.MyModuleAlias.add, 5, 3); var a = 5; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js index 29f77ba8c5..72a1029205 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +import * as MyModule from "./MyModule.bs.js"; -var MyModuleAlias; +var MyModuleAlias = MyModule; export { MyModuleAlias , diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx new file mode 100644 index 0000000000..27ab2e87ef --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx @@ -0,0 +1,14 @@ +/* TypeScript file generated from Wrapper.res by genType. */ +/* eslint-disable import/first */ + + +// @ts-ignore: Implicit any on import +import * as WrapperBS__Es6Import from './Wrapper.bs'; +const WrapperBS: any = WrapperBS__Es6Import; + +// tslint:disable-next-line:interface-over-type-literal +export type MyModuleAlias_t = number; + +export const MyModuleAlias_add: (_1:MyModuleAlias_t, _2:MyModuleAlias_t) => MyModuleAlias_t = WrapperBS.MyModuleAlias.add; + +export const MyModuleAlias: { add: (_1:MyModuleAlias_t, _2:MyModuleAlias_t) => MyModuleAlias_t } = WrapperBS.MyModuleAlias diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res index 5b2290225b..726c2a7f8d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res @@ -1 +1,2 @@ -module MyModuleAlias = MyModule +@genType +module MyModuleAlias = {include MyModule} From d42a8ea2625972b7a0225bf34fe601a09f3a7a9f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 8 Apr 2023 07:46:50 +0200 Subject: [PATCH 3/7] Don't need wrapper to be a separate file. --- .../typescript-react-example/src/Usage.bs.js | 10 +++++++--- .../typescript-react-example/src/Usage.gen.tsx | 2 -- .../typescript-react-example/src/Usage.res | 7 +++++-- .../typescript-react-example/src/Wrapper.bs.js | 10 ---------- .../typescript-react-example/src/Wrapper.gen.tsx | 14 -------------- .../typescript-react-example/src/Wrapper.res | 2 -- 6 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js delete mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx delete mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.res diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js index b64bd4a019..6a96f22cbc 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js @@ -1,13 +1,17 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; -import * as Wrapper from "./Wrapper.bs.js"; +import * as MyModule from "./MyModule.bs.js"; -var b = Curry._2(Wrapper.MyModuleAlias.add, 5, 3); +var Wrapper = { + MyModuleAlias: undefined +}; + +var b = MyModule.add(5, 3); var a = 5; export { + Wrapper , a , b , } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx index 383e5d732c..e15a13284c 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx @@ -6,6 +6,4 @@ import * as UsageBS__Es6Import from './Usage.bs'; const UsageBS: any = UsageBS__Es6Import; -import type {MyModuleAlias_t as Wrapper_MyModuleAlias_t} from './Wrapper.gen'; - export const b: Wrapper_MyModuleAlias_t = UsageBS.b; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.res b/jscomp/gentype_tests/typescript-react-example/src/Usage.res index 4d0e891e0a..59cc9814ee 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.res @@ -1,5 +1,8 @@ -open Wrapper +module Wrapper = { + @genType + module MyModuleAlias = MyModule +} let a = 5 @genType -let b = MyModuleAlias.add(a, 3) +let b = Wrapper.MyModuleAlias.add(a, 3) diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js deleted file mode 100644 index 72a1029205..0000000000 --- a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js +++ /dev/null @@ -1,10 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as MyModule from "./MyModule.bs.js"; - -var MyModuleAlias = MyModule; - -export { - MyModuleAlias , -} -/* No side effect */ diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx deleted file mode 100644 index 27ab2e87ef..0000000000 --- a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx +++ /dev/null @@ -1,14 +0,0 @@ -/* TypeScript file generated from Wrapper.res by genType. */ -/* eslint-disable import/first */ - - -// @ts-ignore: Implicit any on import -import * as WrapperBS__Es6Import from './Wrapper.bs'; -const WrapperBS: any = WrapperBS__Es6Import; - -// tslint:disable-next-line:interface-over-type-literal -export type MyModuleAlias_t = number; - -export const MyModuleAlias_add: (_1:MyModuleAlias_t, _2:MyModuleAlias_t) => MyModuleAlias_t = WrapperBS.MyModuleAlias.add; - -export const MyModuleAlias: { add: (_1:MyModuleAlias_t, _2:MyModuleAlias_t) => MyModuleAlias_t } = WrapperBS.MyModuleAlias diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res deleted file mode 100644 index 726c2a7f8d..0000000000 --- a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res +++ /dev/null @@ -1,2 +0,0 @@ -@genType -module MyModuleAlias = {include MyModule} From 5cb6354841ffd07d0ce723fcb4439c123ddda123 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 8 Apr 2023 09:04:19 +0200 Subject: [PATCH 4/7] Resolve module aliases in local modules. --- jscomp/gentype/Dependencies.ml | 25 +++++++++++++------ .../src/FirstClassModulesInterface.gen.tsx | 8 ++++++ .../src/Usage.gen.tsx | 4 ++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/jscomp/gentype/Dependencies.ml b/jscomp/gentype/Dependencies.ml index 087d33b648..889d0f4891 100644 --- a/jscomp/gentype/Dependencies.ml +++ b/jscomp/gentype/Dependencies.ml @@ -11,19 +11,30 @@ let rec fromPath1 ~config ~typeEnv (path : Path.t) = | Pident id -> ( let name = id |> Ident.name in match typeEnv |> TypeEnv.lookup ~name with - | None -> External name + | None -> (typeEnv, External name) | Some typeEnv1 -> ( + let typeEnv2 = + match typeEnv |> TypeEnv.getModule ~name with + | Some typeEnv2 -> typeEnv2 + | None -> typeEnv1 + in match typeEnv1 |> TypeEnv.expandAliasToExternalModule ~name with - | Some dep -> dep + | Some dep -> (typeEnv2, dep) | None -> let resolvedName = name |> TypeEnv.addModulePath ~typeEnv:typeEnv1 in - Internal resolvedName)) + (typeEnv2, Internal resolvedName))) | Pdot (Pident id, s, _pos) when id |> ScopedPackage.isGeneratedModule ~config -> - External (s |> ScopedPackage.addGeneratedModule ~generatedModule:id) - | Pdot (p, s, _pos) -> Dot (p |> fromPath1 ~config ~typeEnv, s) + ( typeEnv, + External (s |> ScopedPackage.addGeneratedModule ~generatedModule:id) ) + | Pdot (p, s, _pos) -> ( + let typeEnvFromP, dep = p |> fromPath1 ~config ~typeEnv in + match typeEnvFromP |> TypeEnv.expandAliasToExternalModule ~name:s with + | Some dep -> (typeEnvFromP, dep) + | None -> (typeEnvFromP, Dot (dep, s))) | Papply _ -> - Internal ("__Papply_unsupported_genType__" |> ResolvedName.fromString) + ( typeEnv, + Internal ("__Papply_unsupported_genType__" |> ResolvedName.fromString) ) let rec isInternal dep = match dep with @@ -32,7 +43,7 @@ let rec isInternal dep = | Dot (d, _) -> d |> isInternal let fromPath ~config ~typeEnv path = - let dep = path |> fromPath1 ~config ~typeEnv in + let _, dep = path |> fromPath1 ~config ~typeEnv in if !Debug.typeResolution then Log_.item "fromPath path:%s typeEnv:%s %s resolved:%s\n" (path |> Path.name) (typeEnv |> TypeEnv.toString) diff --git a/jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx index c8b25ae3cf..3e3ba806f2 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx @@ -2,8 +2,16 @@ /* eslint-disable import/first */ +// @ts-ignore: Implicit any on import +import * as FirstClassModulesInterfaceBS__Es6Import from './FirstClassModulesInterface.bs'; +const FirstClassModulesInterfaceBS: any = FirstClassModulesInterfaceBS__Es6Import; + // tslint:disable-next-line:interface-over-type-literal export type record = { readonly x: number; readonly y: string }; // tslint:disable-next-line:interface-over-type-literal export type firstClassModule = { readonly x: number }; + +export const MT_x: number = FirstClassModulesInterfaceBS.MT.x; + +export const MT: { x: number } = FirstClassModulesInterfaceBS.MT diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx index e15a13284c..7f23b11fcf 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx @@ -6,4 +6,6 @@ import * as UsageBS__Es6Import from './Usage.bs'; const UsageBS: any = UsageBS__Es6Import; -export const b: Wrapper_MyModuleAlias_t = UsageBS.b; +import type {t as MyModule_t} from './MyModule.gen'; + +export const b: MyModule_t = UsageBS.b; From b94a1d7c0c02b054dc041ef860d08de0bdf17c77 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 8 Apr 2023 09:05:44 +0200 Subject: [PATCH 5/7] Back to having the alias in an separate file. --- .../typescript-react-example/src/Usage.bs.js | 5 ----- .../typescript-react-example/src/Usage.gen.tsx | 4 ++-- .../gentype_tests/typescript-react-example/src/Usage.res | 5 ----- .../typescript-react-example/src/Wrapper.bs.js | 9 +++++++++ .../typescript-react-example/src/Wrapper.gen.tsx | 5 +++++ .../typescript-react-example/src/Wrapper.res | 2 ++ 6 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx create mode 100644 jscomp/gentype_tests/typescript-react-example/src/Wrapper.res diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js index 6a96f22cbc..04b9d76c21 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.bs.js @@ -2,16 +2,11 @@ import * as MyModule from "./MyModule.bs.js"; -var Wrapper = { - MyModuleAlias: undefined -}; - var b = MyModule.add(5, 3); var a = 5; export { - Wrapper , a , b , } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx index 7f23b11fcf..383e5d732c 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.gen.tsx @@ -6,6 +6,6 @@ import * as UsageBS__Es6Import from './Usage.bs'; const UsageBS: any = UsageBS__Es6Import; -import type {t as MyModule_t} from './MyModule.gen'; +import type {MyModuleAlias_t as Wrapper_MyModuleAlias_t} from './Wrapper.gen'; -export const b: MyModule_t = UsageBS.b; +export const b: Wrapper_MyModuleAlias_t = UsageBS.b; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Usage.res b/jscomp/gentype_tests/typescript-react-example/src/Usage.res index 59cc9814ee..12d383e217 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Usage.res +++ b/jscomp/gentype_tests/typescript-react-example/src/Usage.res @@ -1,8 +1,3 @@ -module Wrapper = { - @genType - module MyModuleAlias = MyModule -} - let a = 5 @genType let b = Wrapper.MyModuleAlias.add(a, 3) diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js new file mode 100644 index 0000000000..29f77ba8c5 --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.bs.js @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +var MyModuleAlias; + +export { + MyModuleAlias , +} +/* No side effect */ diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx new file mode 100644 index 0000000000..fc07ae5347 --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx @@ -0,0 +1,5 @@ +/* TypeScript file generated from Wrapper.res by genType. */ +/* eslint-disable import/first */ + + + diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res new file mode 100644 index 0000000000..e874c4662d --- /dev/null +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.res @@ -0,0 +1,2 @@ +@genType +module MyModuleAlias = MyModule From 869a4900b72c7da6b65fbb600111c35c969dac87 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 9 Apr 2023 04:48:35 +0200 Subject: [PATCH 6/7] Expand module aliases. when a module alias is created ```res module A = B ``` expand the definition of B (as in an include) for genType's purposes --- jscomp/gentype/TranslateCoreType.ml | 3 +-- jscomp/gentype/TranslateSignature.ml | 9 ++++++-- jscomp/gentype/TranslateSignatureFromTypes.ml | 9 ++++++-- jscomp/gentype/TranslateStructure.ml | 22 ++++++++++++++----- .../src/TestModuleAliases.gen.tsx | 3 +++ .../src/Wrapper.gen.tsx | 9 ++++++++ 6 files changed, 43 insertions(+), 12 deletions(-) diff --git a/jscomp/gentype/TranslateCoreType.ml b/jscomp/gentype/TranslateCoreType.ml index d97aff69b4..3173744547 100644 --- a/jscomp/gentype/TranslateCoreType.ml +++ b/jscomp/gentype/TranslateCoreType.ml @@ -178,8 +178,7 @@ and translateCoreType_ ~config ~typeVarsGen |> Annotation.hasAttribute Annotation.tagIsString in let asInt = - coreType.ctyp_attributes - |> Annotation.hasAttribute Annotation.tagIsInt + coreType.ctyp_attributes |> Annotation.hasAttribute Annotation.tagIsInt in let lastBsInt = ref (-1) in let noPayloads = diff --git a/jscomp/gentype/TranslateSignature.ml b/jscomp/gentype/TranslateSignature.ml index 932da78028..e3ddd54385 100644 --- a/jscomp/gentype/TranslateSignature.ml +++ b/jscomp/gentype/TranslateSignature.ml @@ -9,7 +9,9 @@ let translateSignatureValue ~config ~outputFileRelative ~resolver ~typeEnv Log_.item "Translate Signature Value %s\n" (val_id |> Ident.name); let typeExpr = val_desc.ctyp_type in let addAnnotationsToFunction type_ = type_ in - match (val_id, val_attributes |> Annotation.fromAttributes ~config ~loc:val_loc) with + match + (val_id, val_attributes |> Annotation.fromAttributes ~config ~loc:val_loc) + with | id, GenType -> id |> Ident.name |> Translation.translateValue ~attributes:val_attributes ~config @@ -118,7 +120,10 @@ and translateSignatureItem ~config ~outputFileRelative ~resolver ~typeEnv let moduleItem = Runtime.newModuleItem ~name:(moduleTypeDeclaration.mtd_id |> Ident.name) in - let config = moduleTypeDeclaration.mtd_attributes |> Annotation.updateConfigForModule ~config in + let config = + moduleTypeDeclaration.mtd_attributes + |> Annotation.updateConfigForModule ~config + in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; moduleTypeDeclaration |> translateModuleTypeDeclaration ~config ~outputFileRelative ~resolver diff --git a/jscomp/gentype/TranslateSignatureFromTypes.ml b/jscomp/gentype/TranslateSignatureFromTypes.ml index 9e798a91b4..df70bfbb41 100644 --- a/jscomp/gentype/TranslateSignatureFromTypes.ml +++ b/jscomp/gentype/TranslateSignatureFromTypes.ml @@ -64,7 +64,10 @@ and translateSignatureItemFromTypes ~config ~outputFileRelative ~resolver } | Types.Sig_module (id, moduleDeclaration, _) -> let moduleItem = Runtime.newModuleItem ~name:(id |> Ident.name) in - let config = moduleDeclaration.md_attributes |> Annotation.updateConfigForModule ~config in + let config = + moduleDeclaration.md_attributes + |> Annotation.updateConfigForModule ~config + in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; moduleDeclaration |> translateModuleDeclarationFromTypes ~config ~outputFileRelative ~resolver @@ -74,7 +77,9 @@ and translateSignatureItemFromTypes ~config ~outputFileRelative ~resolver if !Debug.translation then Log_.item "Translate Sig Value %s\n" name; let moduleItem = Runtime.newModuleItem ~name in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; - if val_attributes |> Annotation.fromAttributes ~config ~loc:val_loc = GenType then + if + val_attributes |> Annotation.fromAttributes ~config ~loc:val_loc = GenType + then name |> Translation.translateValue ~attributes:val_attributes ~config ~docString:(Annotation.getDocString val_attributes) diff --git a/jscomp/gentype/TranslateStructure.ml b/jscomp/gentype/TranslateStructure.ml index 29ab23aba4..3c7a4cb0d8 100644 --- a/jscomp/gentype/TranslateStructure.ml +++ b/jscomp/gentype/TranslateStructure.ml @@ -94,7 +94,10 @@ let translateValueBinding ~config ~outputFileRelative ~resolver ~typeEnv if !Debug.translation then Log_.item "Translate Value Binding %s\n" name; let moduleItem = Runtime.newModuleItem ~name in typeEnv |> TypeEnv.updateModuleItem ~moduleItem; - if vb_attributes |> Annotation.fromAttributes ~config ~loc:vb_pat.pat_loc = GenType + if + vb_attributes + |> Annotation.fromAttributes ~config ~loc:vb_pat.pat_loc + = GenType then id |> Ident.name |> Translation.translateValue ~attributes:vb_attributes ~config @@ -148,6 +151,18 @@ let rec translateModuleBinding ~(config : GenTypeConfig.t) ~outputFileRelative typeEnv |> TypeEnv.updateModuleItem ~moduleItem; let typeEnv = typeEnv |> TypeEnv.newModule ~name in match mb_expr.mod_desc with + | Tmod_ident (path, _) -> ( + let dep = path |> Dependencies.fromPath ~config ~typeEnv in + let internal = dep |> Dependencies.isInternal in + typeEnv |> TypeEnv.addModuleEquation ~dep ~internal; + match Env.scrape_alias mb_expr.mod_env mb_expr.mod_type with + | Mty_signature signature -> + (* Treat module M = N as include N *) + signature + |> TranslateSignatureFromTypes.translateSignatureFromTypes ~config + ~outputFileRelative ~resolver ~typeEnv + |> Translation.combine + | Mty_alias _ | Mty_ident _ | Mty_functor _ -> Translation.empty) | Tmod_structure structure -> let isLetPrivate = mb_attributes |> Annotation.hasAttribute Annotation.tagIsInternLocal @@ -195,11 +210,6 @@ let rec translateModuleBinding ~(config : GenTypeConfig.t) ~outputFileRelative | Mty_alias _ -> logNotImplemented ("Mty_alias " ^ __LOC__); Translation.empty) - | Tmod_ident (path, _) -> - let dep = path |> Dependencies.fromPath ~config ~typeEnv in - let internal = dep |> Dependencies.isInternal in - typeEnv |> TypeEnv.addModuleEquation ~dep ~internal; - Translation.empty | Tmod_functor _ -> logNotImplemented ("Tmod_functor " ^ __LOC__); Translation.empty diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestModuleAliases.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/TestModuleAliases.gen.tsx index 2f6f331f88..3c5e717c8c 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestModuleAliases.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/TestModuleAliases.gen.tsx @@ -14,6 +14,9 @@ import type {Outer_outer as ModuleAliases2_Outer_outer} from './ModuleAliases2.g import type {record as ModuleAliases2_record} from './ModuleAliases2.gen'; +// tslint:disable-next-line:interface-over-type-literal +export type OtherFile_record = { readonly x: number; readonly y: string }; + // tslint:disable-next-line:interface-over-type-literal export type record = ModuleAliases2_record; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx index fc07ae5347..27ab2e87ef 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/Wrapper.gen.tsx @@ -2,4 +2,13 @@ /* eslint-disable import/first */ +// @ts-ignore: Implicit any on import +import * as WrapperBS__Es6Import from './Wrapper.bs'; +const WrapperBS: any = WrapperBS__Es6Import; +// tslint:disable-next-line:interface-over-type-literal +export type MyModuleAlias_t = number; + +export const MyModuleAlias_add: (_1:MyModuleAlias_t, _2:MyModuleAlias_t) => MyModuleAlias_t = WrapperBS.MyModuleAlias.add; + +export const MyModuleAlias: { add: (_1:MyModuleAlias_t, _2:MyModuleAlias_t) => MyModuleAlias_t } = WrapperBS.MyModuleAlias From 67dbb58b7a517704e5b71fa1dba6222d9055a06c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 9 Apr 2023 05:54:08 +0200 Subject: [PATCH 7/7] Update CHANGELOG.md Fixes https://github.com/rescript-lang/rescript-compiler/issues/6112 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b470b74b5f..05824d81c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ https://github.com/rescript-lang/rescript-compiler/pull/5968 https://github.com/ - Customization of runtime representation of variants. This is work in progress. E.g. some restrictions on the input. See comments of the form "TODO: put restriction on the variant definitions allowed, to make sure this never happens". https://github.com/rescript-lang/rescript-compiler/pull/6095 - Introduce untagged variants https://github.com/rescript-lang/rescript-compiler/pull/6103 - GenType: add the option to use the `@genType` annotation at the module level, meaning that all the items in the module should be exported. https://github.com/rescript-lang/rescript-compiler/pull/6113 +- GenType: add support for `@genType` annotations on module definitions. https://github.com/rescript-lang/rescript-compiler/pull/6113 #### :boom: Breaking Change @@ -70,6 +71,7 @@ These are only breaking changes for unformatted code. - Fix parsing uncurried type starting with path https://github.com/rescript-lang/rescript-compiler/pull/6089 - Fix bigInt comparison https://github.com/rescript-lang/rescript-compiler/pull/6097 - Fixed a bug where the async attribute was not preserved when using the `@this` decorator in ReScript functions. This fix allows proper handling of async functions with the `@this` decorator. Issue: https://github.com/rescript-lang/rescript-compiler/issues/6100 +- Fix issue with GenType and module aliases https://github.com/rescript-lang/rescript-compiler/issues/6112 #### :nail_care: Polish