Skip to content

Commit b95dd7b

Browse files
committed
add missing jsdocs
1 parent 0e0a0b2 commit b95dd7b

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

crates/js-component-bindgen/src/ts_bindgen.rs

+31-7
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,18 @@ impl<'a> TsInterface<'a> {
717717
.payload_type_of_option_result_of_next_method_of_resource(&self.resolve)
718718
{
719719
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+
);
721732
iface.print_ty(&payload);
722733
iface.src.push_str(">;\n");
723734
}
@@ -920,8 +931,9 @@ impl<'a> TsInterface<'a> {
920931
Type::Id(id).variant_case_type_defs_where_they_are_all_handles(self.resolve)
921932
{
922933
self.docs(docs);
934+
let type_union_name = name.to_upper_camel_case();
923935
self.src
924-
.push_str(&format!("export type {} = ", name.to_upper_camel_case()));
936+
.push_str(&format!("export type {type_union_name} = "));
925937
for (i, case_type_def) in case_type_defs.iter().enumerate() {
926938
if i > 0 {
927939
self.src.push_str(" | ");
@@ -931,14 +943,26 @@ impl<'a> TsInterface<'a> {
931943
}
932944
self.src.push_str(";\n");
933945

934-
let type_enum_name = format!("{}_type", name).to_upper_camel_case();
946+
let type_enum_name = format!("{type_union_name}Type");
935947

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+
));
938956
for type_def in &case_type_defs {
939957
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+
));
942966
}
943967
self.src.push_str("}\n");
944968

0 commit comments

Comments
 (0)