@@ -59,7 +59,7 @@ let traslate_declaration_kind ~config ~loc ~output_file_relative ~resolver
5959 | false -> None
6060 (* one means don't know *)
6161 in
62- let import_string_opt, name_as, _import_exact_opt, remote_export_name_opt =
62+ let import_string_opt, name_as =
6363 type_attributes |> Annotation. get_attribute_import_renaming
6464 in
6565 let satisfies_opt = type_attributes |> Annotation. get_attribute_satisfies in
@@ -99,9 +99,8 @@ let traslate_declaration_kind ~config ~loc ~output_file_relative ~resolver
9999 (translation : TranslateTypeExprFromTypes.translation ) =
100100 let export_from_type_declaration =
101101 type_name
102- |> create_export_type_from_type_declaration ~annotation: annotation_for_export
103- ~loc ~name_as
104- ~opaque
102+ |> create_export_type_from_type_declaration
103+ ~annotation: annotation_for_export ~loc ~name_as ~opaque
105104 ~type_: (apply_satisfies_wrapper translation.type_)
106105 ~type_env ~doc_string ~type_vars
107106 in
@@ -173,35 +172,31 @@ let traslate_declaration_kind ~config ~loc ~output_file_relative ~resolver
173172 let name_with_module_path =
174173 typeName_ |> TypeEnv. add_module_path ~type_env |> ResolvedName. to_string
175174 in
176- (* Use the remote export name (if provided) to build the import and alias.
177- Preserve casing from the TS source exactly. *)
178- let remote_type_name =
179- match remote_export_name_opt with
180- | Some s -> s
181- | None -> name_with_module_path
175+ let type_name, as_type_name =
176+ match name_as with
177+ | Some as_string -> (as_string, " $$" ^ name_with_module_path)
178+ | None -> (name_with_module_path, " $$" ^ name_with_module_path)
182179 in
183- let type_name = remote_type_name in
184- let as_type_name = remote_type_name ^ " $TypeScript" in
185- let import_path = import_string |> ImportPath. from_string_unsafe in
186- let base_import =
187- {CodeItem. type_name; as_type_name = Some as_type_name; import_path}
180+ let import_types =
181+ [
182+ {
183+ CodeItem. type_name;
184+ as_type_name = Some as_type_name;
185+ import_path = import_string |> ImportPath. from_string_unsafe;
186+ };
187+ ]
188188 in
189- (* Only import the aliased TypeScript type; no wrappers or extra aliases. *)
190- let import_types = [base_import] in
191189 let export_from_type_declaration =
192190 (* Make the imported type usable from other modules by exporting it too. *)
193- let export_type_body =
194- as_type_name
195- |> ident ~type_args: (type_vars |> List. map (fun s -> TypeVar s))
196- in
197191 typeName_
198192 |> create_export_type_from_type_declaration ~doc_string
199193 ~annotation: GenType ~loc ~name_as: None ~opaque: (Some false )
200- ~type_: export_type_body ~type_env ~type_vars
194+ ~type_:
195+ (as_type_name
196+ |> ident ~type_args: (type_vars |> List. map (fun s -> TypeVar s)))
197+ ~type_env ~type_vars
201198 in
202- [
203- {CodeItem. import_types; export_from_type_declaration};
204- ]
199+ [{CodeItem. import_types; export_from_type_declaration}]
205200 | (GeneralDeclarationFromTypes None | GeneralDeclaration None ), None ->
206201 {
207202 CodeItem. import_types = [] ;
@@ -248,8 +243,7 @@ let traslate_declaration_kind ~config ~loc ~output_file_relative ~resolver
248243 | _ -> translation.type_
249244 in
250245 {translation with type_ = apply_satisfies_wrapper type_}
251- |> handle_general_declaration
252- |> return_type_declaration
246+ |> handle_general_declaration |> return_type_declaration
253247 | RecordDeclarationFromTypes label_declarations , None ->
254248 let {TranslateTypeExprFromTypes. dependencies; type_} =
255249 label_declarations |> translate_label_declarations
@@ -264,8 +258,8 @@ let traslate_declaration_kind ~config ~loc ~output_file_relative ~resolver
264258 export_from_type_declaration =
265259 type_name
266260 |> create_export_type_from_type_declaration ~doc_string
267- ~annotation: annotation_for_export ~loc
268- ~name_as ~opaque ~ type_: (apply_satisfies_wrapper type_)
261+ ~annotation: annotation_for_export ~loc ~name_as ~opaque
262+ ~type_: (apply_satisfies_wrapper type_)
269263 ~type_env ~type_vars ;
270264 }
271265 |> return_type_declaration
0 commit comments