1
1
/**
2
- * ----------------------------------------------------------------------------
3
2
* UPDATE:
4
3
*
5
4
* TODO - In next major version, we can remove this file entirely due to TS PR 57223
6
5
* https://github.com/microsoft/TypeScript/pull/57223
7
- * ----------------------------------------------------------------------------
8
6
*
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
10
8
* elision to break during emit for nodes which have been transformed. Specifically, if the 'original' property is set,
11
9
* elision functionality no longer works.
12
10
*
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_
14
12
*
15
13
* The logic herein compensates for that issue by recreating type elision separately so that the transformer can update
16
14
* the clause with the properly elided information
17
15
*
18
16
* 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
22
21
*
23
22
* @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;
27
26
*
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";
31
30
*
32
- * // Expected output for b.js
33
- * import { B } from ' ./b'
31
+ * // Expected output for b.js
32
+ * import { B } from " ./b";
34
33
*
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";
38
37
*/
39
38
import { ImportOrExportDeclaration , VisitorContext } from "../types" ;
40
39
import {
@@ -60,10 +59,10 @@ import {
60
59
/* ****************************************************************************************************************** */
61
60
62
61
/**
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
65
64
*
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
67
66
*/
68
67
export function elideImportOrExportDeclaration < T extends ImportOrExportDeclaration > (
69
68
context : VisitorContext ,
@@ -208,10 +207,7 @@ export function elideImportOrExportDeclaration(
208
207
return ! node . isTypeOnly && shouldEmitAliasDeclaration ( node ) ? node : undefined ;
209
208
}
210
209
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. */
215
211
function visitNamedExports ( node : NamedExports , allowEmpty : boolean ) : VisitResult < NamedExports > | undefined {
216
212
// Elide the named exports if all of its export specifiers were elided.
217
213
const elements = visitNodes ( node . elements , < Visitor > visitExportSpecifier , isExportSpecifier ) ;
0 commit comments