@@ -717,7 +717,18 @@ impl<'a> TsInterface<'a> {
717
717
. payload_type_of_option_result_of_next_method_of_resource ( & self . resolve )
718
718
{
719
719
let iface = self . resources . get_mut ( resource) . unwrap ( ) ;
720
- iface. src . push_str ( & "[Symbol.iterator](): Iterator<" ) ;
720
+ iface. src . push_str (
721
+ & "
722
+ /**
723
+ * Returns an iterator over `" ,
724
+ ) ;
725
+ iface. print_ty ( & payload) ;
726
+ iface. src . push_str (
727
+ & "` objects. Called by the semantics of the for-of statement.
728
+ */
729
+ [Symbol.iterator](): Iterator<
730
+ " ,
731
+ ) ;
721
732
iface. print_ty ( & payload) ;
722
733
iface. src . push_str ( ">;\n " ) ;
723
734
}
@@ -920,8 +931,9 @@ impl<'a> TsInterface<'a> {
920
931
Type :: Id ( id) . variant_case_type_defs_where_they_are_all_handles ( self . resolve )
921
932
{
922
933
self . docs ( docs) ;
934
+ let type_union_name = name. to_upper_camel_case ( ) ;
923
935
self . src
924
- . push_str ( & format ! ( "export type {} = " , name . to_upper_camel_case ( ) ) ) ;
936
+ . push_str ( & format ! ( "export type {type_union_name } = " ) ) ;
925
937
for ( i, case_type_def) in case_type_defs. iter ( ) . enumerate ( ) {
926
938
if i > 0 {
927
939
self . src . push_str ( " | " ) ;
@@ -931,14 +943,26 @@ impl<'a> TsInterface<'a> {
931
943
}
932
944
self . src . push_str ( ";\n " ) ;
933
945
934
- let type_enum_name = format ! ( "{}_type" , name ) . to_upper_camel_case ( ) ;
946
+ let type_enum_name = format ! ( "{type_union_name}Type" ) ;
935
947
936
- self . src
937
- . push_str ( & format ! ( "export enum {type_enum_name} {{\n " ) ) ;
948
+ self . src . push_str ( & format ! (
949
+ "
950
+ /**
951
+ * Enumerates different variants of the `{type_union_name}` type.
952
+ */
953
+ export enum {type_enum_name} {{
954
+ "
955
+ ) ) ;
938
956
for type_def in & case_type_defs {
939
957
let class_name = type_def. name . as_ref ( ) . unwrap ( ) . to_upper_camel_case ( ) ;
940
- self . src
941
- . push_str ( & format ! ( "{class_name} = '{class_name}',\n " ) ) ;
958
+ self . src . push_str ( & format ! (
959
+ "
960
+ /**
961
+ * Represents a variant of type `{class_name}`.
962
+ */
963
+ {class_name} = '{class_name}',
964
+ "
965
+ ) ) ;
942
966
}
943
967
self . src . push_str ( "}\n " ) ;
944
968
0 commit comments