Make rename_all compatible with tuple and unit structs as a no-op attribute (#422)

This commit is contained in:
Gustavo Shigueo
2025-07-08 08:28:29 -03:00
committed by GitHub
parent 3bd4124bd1
commit f63dd5fbc4
2 changed files with 2 additions and 6 deletions

View File

@@ -132,10 +132,6 @@ impl Attr for StructAttr {
if self.tag.is_some() {
syn_err!("`tag` cannot be used with unit or tuple structs");
}
if self.rename_all.is_some() {
syn_err!("`rename_all` cannot be used with unit or tuple structs");
}
}
Ok(())

View File

@@ -24,7 +24,7 @@ fn test_newtype() {
}
#[derive(TS)]
#[ts(export, export_to = "tuple/")]
#[ts(export, export_to = "tuple/", rename_all = "camelCase")] // rename_all should compile, but it's a noop
struct TupleNewType(String, i32, (i32, i32));
#[test]
@@ -36,7 +36,7 @@ fn test_tuple_newtype() {
}
#[derive(TS)]
#[ts(export, export_to = "tuple/")]
#[ts(export, export_to = "tuple/", rename_all = "kebab-case")]
struct Dep1;
#[derive(TS)]