Skip to content

In GenType only export types (not values) from module types. #6516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion jscomp/gentype/TranslateSignature.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 22 additions & 13 deletions jscomp/gentype_tests/typescript-react-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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