Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,10 @@ impl Gen for ExportNamedDeclaration<'_> {
p.needs_semicolon = false;
}
} else {
if self.export_kind.is_type() {
p.print_hard_space();
p.print_str("type");
}
p.print_soft_space();
p.print_ascii_byte(b'{');
if !self.specifiers.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_codegen/tests/integration/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use oxc_span::SourceType;
pub fn test_with_parse_options(source_text: &str, expected: &str, parse_options: ParseOptions) {
let allocator = Allocator::default();
let ret =
Parser::new(&allocator, source_text, SourceType::jsx()).with_options(parse_options).parse();
Parser::new(&allocator, source_text, SourceType::tsx()).with_options(parse_options).parse();
let result = CodeGenerator::new().build(&ret.program).code;
assert_eq!(result, expected, "\nfor source: {source_text}");
}
Expand All @@ -24,7 +24,7 @@ pub fn test_same(source_text: &str) {

#[track_caller]
pub fn test_options(source_text: &str, expected: &str, options: CodegenOptions) {
test_options_with_source_type(source_text, expected, SourceType::jsx(), options);
test_options_with_source_type(source_text, expected, SourceType::tsx(), options);
}

#[track_caller]
Expand Down
7 changes: 7 additions & 0 deletions crates/oxc_codegen/tests/integration/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ fn module_decl() {
);
}

#[test]
fn export_type() {
test_same("export type {} from \"mod\";\n");
test_same("export type { Foo } from \"mod\";\n");
test_same("export { type Foo, type Bar } from \"mod\";\n");
}

#[test]
fn expr() {
test("new (foo()).bar();", "new (foo()).bar();\n");
Expand Down
Loading