mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 12:49:21 +03:00
fix(ecmascript/codegen): TsQualifiedName has trailing dot (#1268)
Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
This commit is contained in:
parent
0ead8dc403
commit
b760c7c9c7
@ -78,6 +78,17 @@ pub(crate) fn assert_min(from: &str, to: &str) {
|
||||
assert_eq!(DebugUsingDisplay(out.trim()), DebugUsingDisplay(to),);
|
||||
}
|
||||
|
||||
/// Clone of the regular `assert_min` function but with TypeScript syntax.
|
||||
pub(crate) fn assert_min_typescript(from: &str, to: &str) {
|
||||
let out = parse_then_emit(
|
||||
from,
|
||||
Config { minify: true },
|
||||
Syntax::Typescript(Default::default()),
|
||||
);
|
||||
|
||||
assert_eq!(DebugUsingDisplay(out.trim()), DebugUsingDisplay(to),);
|
||||
}
|
||||
|
||||
pub(crate) fn assert_pretty(from: &str, to: &str) {
|
||||
let out = parse_then_emit(from, Config { minify: false }, Syntax::default());
|
||||
|
||||
|
@ -113,7 +113,6 @@ impl<'a> Emitter<'a> {
|
||||
match n {
|
||||
TsEntityName::TsQualifiedName(n) => {
|
||||
emit!(n);
|
||||
punct!(".");
|
||||
}
|
||||
TsEntityName::Ident(n) => emit!(n),
|
||||
}
|
||||
@ -973,3 +972,16 @@ impl<'a> Emitter<'a> {
|
||||
self.emit_list(n.span, Some(&n.types), ListFormat::UnionTypeConstituents)?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::assert_min_typescript;
|
||||
|
||||
#[test]
|
||||
fn qualified_type() {
|
||||
assert_min_typescript(
|
||||
"var memory: WebAssembly.Memory;",
|
||||
"var memory:WebAssembly.Memory;",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user