fix(es/codegen): Fix codegen of type-only export declarations (#8447)

**Description:**

This fixes the emit for `export type { } from "..."` and `export { type A } from "..."`.
This commit is contained in:
David Sherret 2023-12-21 22:25:52 -05:00 committed by GitHub
parent a9f25b2fb6
commit 65dec905c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 2 deletions

View File

@ -415,6 +415,11 @@ where
srcmap!(node, true);
if node.is_type_only {
keyword!("type");
space!();
}
if let Some(exported) = &node.exported {
emit!(node.orig);
space!();
@ -470,7 +475,12 @@ where
keyword!("export");
if node.type_only {
space!();
keyword!("type");
}
formatting_space!();
if let Some(spec) = namespace_spec {
emit!(spec);
if has_named_specs {
@ -521,7 +531,15 @@ where
srcmap!(node, true);
keyword!("export");
formatting_space!();
if node.type_only {
space!();
keyword!("type");
space!();
} else {
formatting_space!();
}
punct!("*");
formatting_space!();
keyword!("from");

View File

@ -0,0 +1,3 @@
export type * as test from "./a.ts";
export type { a } from "./a.ts";
export { b, type b2 } from "./b.ts";

View File

@ -0,0 +1,3 @@
export type * as test from "./a.ts";
export type { a } from "./a.ts";
export { b, type b2 } from "./b.ts";

View File

@ -0,0 +1 @@
export type*as test from"./a.ts";export type{a}from"./a.ts";export{b,type b2}from"./b.ts";

View File

@ -0,0 +1,4 @@
import type test from "./a.ts";
import type { a } from "./a.ts";
import type * as name from "./a.ts";
import { b, type c } from "./a.ts";

View File

@ -0,0 +1,4 @@
import type test from "./a.ts";
import type { a } from "./a.ts";
import type * as name from "./a.ts";
import { b, type c } from "./a.ts";

View File

@ -0,0 +1 @@
import type test from"./a.ts";import type{a}from"./a.ts";import type*as name from"./a.ts";import{b,type c}from"./a.ts";

View File

@ -1,2 +1,3 @@
import Test1 = MyNamespace.Test1;
import Test2 = Test1;
export import Test3 = Test1;

View File

@ -1,2 +1,3 @@
import Test1 = MyNamespace.Test1;
import Test2 = Test1;
export import Test3 = Test1;

View File

@ -1 +1 @@
import Test1=MyNamespace.Test1;import Test2=Test1;
import Test1=MyNamespace.Test1;import Test2=Test1;export import Test3=Test1;