11/**
2- * ----------------------------------------------------------------------------
32 * UPDATE:
43 *
54 * TODO - In next major version, we can remove this file entirely due to TS PR 57223
65 * https://github.com/microsoft/TypeScript/pull/57223
7- * ----------------------------------------------------------------------------
86 *
9- * This file and its contents are due to an issue in TypeScript (affecting *at least* up to 4.1) which causes type
7+ * This file and its contents are due to an issue in TypeScript (affecting _at least_ up to 4.1) which causes type
108 * elision to break during emit for nodes which have been transformed. Specifically, if the 'original' property is set,
119 * elision functionality no longer works.
1210 *
13- * This results in module specifiers for types being output in import/export declarations in the compiled *JS files*
11+ * This results in module specifiers for types being output in import/export declarations in the compiled _JS files_
1412 *
1513 * The logic herein compensates for that issue by recreating type elision separately so that the transformer can update
1614 * the clause with the properly elided information
1715 *
1816 * Issues:
19- * @see https://github.com/LeDDGroup/typescript-transform-paths/issues/184
20- * @see https://github.com/microsoft/TypeScript/issues/40603
21- * @see https://github.com/microsoft/TypeScript/issues/31446
17+ *
18+ * - See https://github.com/LeDDGroup/typescript-transform-paths/issues/184
19+ * - See https://github.com/microsoft/TypeScript/issues/40603
20+ * - See https://github.com/microsoft/TypeScript/issues/31446
2221 *
2322 * @example
24- * // a.ts
25- * export type A = string
26- * export const B = 2
23+ * // a.ts
24+ * export type A = string;
25+ * export const B = 2;
2726 *
28- * // b.ts
29- * import { A, B } from ' ./b'
30- * export { A } from ' ./b'
27+ * // b.ts
28+ * import { A, B } from " ./b";
29+ * export { A } from " ./b";
3130 *
32- * // Expected output for b.js
33- * import { B } from ' ./b'
31+ * // Expected output for b.js
32+ * import { B } from " ./b";
3433 *
35- * // Actual output for b.js
36- * import { A, B } from ' ./b'
37- * export { A } from ' ./b'
34+ * // Actual output for b.js
35+ * import { A, B } from " ./b";
36+ * export { A } from " ./b";
3837 */
3938import { ImportOrExportDeclaration , VisitorContext } from "../types" ;
4039import {
@@ -60,10 +59,10 @@ import {
6059/* ****************************************************************************************************************** */
6160
6261/**
63- * Get import / export clause for node (replicates TS elision behaviour for js files)
64- * See notes in get-import-export-clause.ts header for why this is necessary
62+ * Get import / export clause for node (replicates TS elision behaviour for js files) See notes in
63+ * get-import-export-clause.ts header for why this is necessary
6564 *
66- * @returns import or export clause or undefined if it entire declaration should be elided
65+ * @returns Import or export clause or undefined if it entire declaration should be elided
6766 */
6867export function elideImportOrExportDeclaration < T extends ImportOrExportDeclaration > (
6968 context : VisitorContext ,
@@ -208,10 +207,7 @@ export function elideImportOrExportDeclaration(
208207 return ! node . isTypeOnly && shouldEmitAliasDeclaration ( node ) ? node : undefined ;
209208 }
210209
211- /**
212- * Visits named exports, eliding it if it does not contain an export specifier that
213- * resolves to a value.
214- */
210+ /** Visits named exports, eliding it if it does not contain an export specifier that resolves to a value. */
215211 function visitNamedExports ( node : NamedExports , allowEmpty : boolean ) : VisitResult < NamedExports > | undefined {
216212 // Elide the named exports if all of its export specifiers were elided.
217213 const elements = visitNodes ( node . elements , < Visitor > visitExportSpecifier , isExportSpecifier ) ;
0 commit comments