Skip to content

Commit 2f4af2a

Browse files
committed
add missing jsdocs
1 parent 0e0a0b2 commit 2f4af2a

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

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

+26-7
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,13 @@ 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(&format!(
721+
"
722+
/**
723+
* Implements the `Symbol.iterator` API for `{resource}`.
724+
[Symbol.iterator](): Iterator<
725+
"
726+
));
721727
iface.print_ty(&payload);
722728
iface.src.push_str(">;\n");
723729
}
@@ -920,8 +926,9 @@ impl<'a> TsInterface<'a> {
920926
Type::Id(id).variant_case_type_defs_where_they_are_all_handles(self.resolve)
921927
{
922928
self.docs(docs);
929+
let type_union_name = name.to_upper_camel_case();
923930
self.src
924-
.push_str(&format!("export type {} = ", name.to_upper_camel_case()));
931+
.push_str(&format!("export type {type_union_name} = "));
925932
for (i, case_type_def) in case_type_defs.iter().enumerate() {
926933
if i > 0 {
927934
self.src.push_str(" | ");
@@ -931,14 +938,26 @@ impl<'a> TsInterface<'a> {
931938
}
932939
self.src.push_str(";\n");
933940

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

936-
self.src
937-
.push_str(&format!("export enum {type_enum_name} {{\n"));
943+
self.src.push_str(&format!(
944+
"
945+
/**
946+
* Enumerates different variants of the `{type_union_name}` type.
947+
*/
948+
export enum {type_enum_name} {{
949+
"
950+
));
938951
for type_def in &case_type_defs {
939952
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"));
953+
self.src.push_str(&format!(
954+
"
955+
/**
956+
* Represents a variant of type `{class_name}`.
957+
*/
958+
{class_name} = '{class_name}',
959+
"
960+
));
942961
}
943962
self.src.push_str("}\n");
944963

0 commit comments

Comments
 (0)