diff --git a/CHANGELOG.md b/CHANGELOG.md index 186e53abef..9068f87a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Fix accidental removal of `Belt.Result.Ok` and `Belt.Result.Error` constructors in rc.5 https://github.com/rescript-lang/rescript-compiler/pull/6514 - Add missing check that the runtime representation of variants matches implementation and interface. https://github.com/rescript-lang/rescript-compiler/pull/6513/files +- GenType: only export types (not values) from module types. https://github.com/rescript-lang/rescript-compiler/pull/6516 # 11.0.0-rc.7 diff --git a/jscomp/gentype/TranslateSignature.ml b/jscomp/gentype/TranslateSignature.ml index bf719be5c0..a38890a36c 100644 --- a/jscomp/gentype/TranslateSignature.ml +++ b/jscomp/gentype/TranslateSignature.ml @@ -61,8 +61,18 @@ and translateModuleTypeDeclaration ~config ~outputFileRelative ~resolver match mtd_type.mty_desc with | Tmty_signature signature -> let name = mtd_id |> Ident.name in + (* Only translate types *) + let signature_without_values = + { + signature with + sig_items = + Ext_list.filter signature.sig_items (function + | {sig_desc = Tsig_value _} -> false + | _ -> true); + } + in let translation = - signature + signature_without_values |> translateSignature ~config ~outputFileRelative ~resolver ~typeEnv:(typeEnv |> TypeEnv.newModuleType ~name ~signature) |> Translation.combine diff --git a/jscomp/gentype_tests/typescript-react-example/package-lock.json b/jscomp/gentype_tests/typescript-react-example/package-lock.json index a4283beaac..c02269dfe5 100644 --- a/jscomp/gentype_tests/typescript-react-example/package-lock.json +++ b/jscomp/gentype_tests/typescript-react-example/package-lock.json @@ -22,6 +22,26 @@ "typescript": "^5.2.2" } }, + "../../..": { + "name": "rescript", + "version": "11.0.0-rc.8", + "dev": true, + "hasInstallScript": true, + "license": "SEE LICENSE IN LICENSE", + "bin": { + "bsc": "bsc", + "bstracing": "lib/bstracing", + "rescript": "rescript" + }, + "devDependencies": { + "mocha": "10.1.0", + "nyc": "15.0.0", + "prettier": "2.7.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -1399,19 +1419,8 @@ } }, "node_modules/rescript": { - "version": "11.0.0-rc.7", - "resolved": "file:../../..", - "dev": true, - "hasInstallScript": true, - "license": "SEE LICENSE IN LICENSE", - "bin": { - "bsc": "bsc", - "bstracing": "lib/bstracing", - "rescript": "rescript" - }, - "engines": { - "node": ">=10" - } + "resolved": "../../..", + "link": true }, "node_modules/resolve-from": { "version": "4.0.0", 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 6812f915cf..6da111a8aa 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx +++ b/jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx @@ -3,13 +3,6 @@ /* eslint-disable */ /* tslint:disable */ -import * as FirstClassModulesInterfaceBS__Es6Import from './FirstClassModulesInterface.bs'; -const FirstClassModulesInterfaceBS: any = FirstClassModulesInterfaceBS__Es6Import; - export type record = { readonly x: number; readonly y: string }; export type firstClassModule = { readonly x: number }; - -export const MT_x: number = FirstClassModulesInterfaceBS.MT.x; - -export const MT: { x: number } = FirstClassModulesInterfaceBS.MT