Skip to content

Commit

Permalink
* Change NodeKind to NodeType
Browse files Browse the repository at this point in the history
* Update documentation to include backticks around keywords/types
* Update documentation to use the word "type" instead of "kind"
  • Loading branch information
mjoerussell committed Dec 5, 2024
1 parent 55687a4 commit 5b19b7b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions crates/js-component-bindgen/src/ts_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ impl TsBindgen {
{
let name = ty.name.as_ref().unwrap();
uwriteln!(gen.src, "export {{ {} }};", name.to_upper_camel_case());
let variant_enum_name = format!("{}_kind", name).to_upper_camel_case();
uwriteln!(gen.src, "export {{ {variant_enum_name} }};");
let type_enum_name = format!("{}_type", name).to_upper_camel_case();
uwriteln!(gen.src, "export {{ {type_enum_name} }};");
}
}
_ => {}
Expand Down Expand Up @@ -931,10 +931,10 @@ impl<'a> TsInterface<'a> {
}
self.src.push_str(";\n");

let variant_enum_name = format!("{}_kind", name).to_upper_camel_case();
let type_enum_name = format!("{}_type", name).to_upper_camel_case();

self.src
.push_str(&format!("export enum {variant_enum_name} {{\n"));
.push_str(&format!("export enum {type_enum_name} {{\n"));
for type_def in &case_type_defs {
let class_name = type_def.name.as_ref().unwrap().to_upper_camel_case();
self.src
Expand All @@ -954,17 +954,17 @@ impl<'a> TsInterface<'a> {
&mut body,
"
/**
* The variant of {variant_enum_name} that corresponds to this class.
* The variant of `{type_enum_name}` that corresponds to this class.
*/
readonly type = {variant_enum_name}.{class_name};
readonly type = {type_enum_name}.{class_name};
/**
* Coerce this variant to a {class_name}, or undefined if this is not the correct kind.
* Coerce this variant to a `{class_name}`, or `undefined` if this is not the correct type.
*/
as{class_name}(): this;
/**
* Return `true` if this object is an instance of {class_name}.
* Return `true` if this object is an instance of `{class_name}`.
*/
is{class_name}(): this is {class_name};
"
Expand All @@ -975,12 +975,12 @@ impl<'a> TsInterface<'a> {
&mut body,
"
/**
* Coerce this variant to a `{class_name}`, or `undefined` if this is not the correct kind.
* Coerce this variant to a `{class_name}`, or `undefined` if this is not the correct type.
*/
as{class_name}(): undefined;
/**
* Return `true` if this object is an instance of {class_name}.
* Return `true` if this object is an instance of `{class_name}`.
*/
is{class_name}(): false;
"
Expand Down

0 comments on commit 5b19b7b

Please sign in to comment.