mirror of
https://github.com/swc-project/swc.git
synced 2024-12-18 11:11:30 +03:00
fix(es/typescript): Fix name
of decorated classes (#3689)
This commit is contained in:
parent
738d153609
commit
1e49fcd44d
@ -900,6 +900,37 @@ fn opt_source_file_name_1() {
|
||||
assert!(map.contains("entry-foo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_2224() {
|
||||
let output = str_with_opt(
|
||||
r#"
|
||||
const Injectable = () => {};
|
||||
|
||||
@Injectable
|
||||
export class TestClass {
|
||||
private readonly property = TestClass.name;
|
||||
}"#,
|
||||
Options {
|
||||
is_module: IsModule::Bool(true),
|
||||
config: Config {
|
||||
jsc: JscConfig {
|
||||
syntax: Some(Syntax::Typescript(TsConfig {
|
||||
decorators: true,
|
||||
..Default::default()
|
||||
})),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
println!("{}", output);
|
||||
|
||||
assert!(output.contains("this.property = TestClass.name"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bom() {
|
||||
project("tests/projects/bom")
|
||||
|
@ -411,8 +411,10 @@ where
|
||||
} else {
|
||||
for m in class.body.iter_mut() {
|
||||
if let ClassMember::ClassProp(m) = m {
|
||||
if let Some(orig_ident) = &orig_ident {
|
||||
replace_ident(&mut m.value, orig_ident.to_id(), &ident)
|
||||
if m.is_static {
|
||||
if let Some(orig_ident) = &orig_ident {
|
||||
replace_ident(&mut m.value, orig_ident.to_id(), &ident)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user