Skip to content

Commit 78c3b9a

Browse files
committed
In GenType only export types (not values) from module types.
1 parent b3e7e29 commit 78c3b9a

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
- Fix accidental removal of `Belt.Result.Ok` and `Belt.Result.Error` constructors in rc.5 https://github.com/rescript-lang/rescript-compiler/pull/6514
2121
- Add missing check that the runtime representation of variants matches implementation and interface. https://github.com/rescript-lang/rescript-compiler/pull/6513/files
22+
- GenType: only export types (not values) from module types. https://github.com/rescript-lang/rescript-compiler/pull/6516
2223

2324
# 11.0.0-rc.7
2425

jscomp/gentype/TranslateSignature.ml

+11-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,18 @@ and translateModuleTypeDeclaration ~config ~outputFileRelative ~resolver
6161
match mtd_type.mty_desc with
6262
| Tmty_signature signature ->
6363
let name = mtd_id |> Ident.name in
64+
(* Only translate types *)
65+
let signature_without_values =
66+
{
67+
signature with
68+
sig_items =
69+
Ext_list.filter signature.sig_items (function
70+
| {sig_desc = Tsig_value _} -> false
71+
| _ -> true);
72+
}
73+
in
6474
let translation =
65-
signature
75+
signature_without_values
6676
|> translateSignature ~config ~outputFileRelative ~resolver
6777
~typeEnv:(typeEnv |> TypeEnv.newModuleType ~name ~signature)
6878
|> Translation.combine

jscomp/gentype_tests/typescript-react-example/package-lock.json

+22-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/gentype_tests/typescript-react-example/src/FirstClassModulesInterface.gen.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
/* eslint-disable */
44
/* tslint:disable */
55

6-
import * as FirstClassModulesInterfaceBS__Es6Import from './FirstClassModulesInterface.bs';
7-
const FirstClassModulesInterfaceBS: any = FirstClassModulesInterfaceBS__Es6Import;
8-
96
export type record = { readonly x: number; readonly y: string };
107

118
export type firstClassModule = { readonly x: number };
12-
13-
export const MT_x: number = FirstClassModulesInterfaceBS.MT.x;
14-
15-
export const MT: { x: number } = FirstClassModulesInterfaceBS.MT

0 commit comments

Comments
 (0)