fix(ecmascript/codegen): TsQualifiedName has trailing dot (#1268)

Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
This commit is contained in:
Liam Murphy 2020-12-21 00:27:31 +11:00 committed by GitHub
parent 0ead8dc403
commit b760c7c9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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());

View File

@ -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;",
);
}
}