ember-estree 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/print.js +17 -5
package/package.json
CHANGED
package/src/print.js
CHANGED
|
@@ -373,6 +373,8 @@ export function print(node) {
|
|
|
373
373
|
const attrs = (node.attributes ?? []).map(print);
|
|
374
374
|
const attrStr = attrs.length ? ` with { ${attrs.join(", ")} }` : "";
|
|
375
375
|
if (specs.length === 0) return `import ${source}${attrStr};`;
|
|
376
|
+
// `import type { ... }` — a type-only import declaration.
|
|
377
|
+
const typeKind = node.importKind === "type" ? "type " : "";
|
|
376
378
|
const defaultSpec = specs.find(
|
|
377
379
|
(_, i) => node.specifiers[i].type === "ImportDefaultSpecifier",
|
|
378
380
|
);
|
|
@@ -382,7 +384,7 @@ export function print(node) {
|
|
|
382
384
|
if (defaultSpec) parts.push(defaultSpec);
|
|
383
385
|
if (nsSpec) parts.push(print(nsSpec));
|
|
384
386
|
if (namedSpecs.length) parts.push(`{ ${namedSpecs.join(", ")} }`);
|
|
385
|
-
return `import ${parts.join(", ")} from ${source}${attrStr};`;
|
|
387
|
+
return `import ${typeKind}${parts.join(", ")} from ${source}${attrStr};`;
|
|
386
388
|
}
|
|
387
389
|
|
|
388
390
|
case "ImportDefaultSpecifier":
|
|
@@ -391,7 +393,9 @@ export function print(node) {
|
|
|
391
393
|
case "ImportSpecifier": {
|
|
392
394
|
const imported = print(node.imported);
|
|
393
395
|
const local = print(node.local);
|
|
394
|
-
|
|
396
|
+
const spec = imported === local ? imported : `${imported} as ${local}`;
|
|
397
|
+
// Inline `import { type Foo }` modifier.
|
|
398
|
+
return node.importKind === "type" ? `type ${spec}` : spec;
|
|
395
399
|
}
|
|
396
400
|
|
|
397
401
|
case "ImportNamespaceSpecifier":
|
|
@@ -408,19 +412,24 @@ export function print(node) {
|
|
|
408
412
|
if (node.specifiers?.length) {
|
|
409
413
|
const specs = node.specifiers.map(print).join(", ");
|
|
410
414
|
const from = node.source ? ` from ${print(node.source)}` : "";
|
|
411
|
-
|
|
415
|
+
// `export type { ... }` — a type-only export declaration.
|
|
416
|
+
const typeKind = node.exportKind === "type" ? "type " : "";
|
|
417
|
+
return `export ${typeKind}{ ${specs} }${from};`;
|
|
412
418
|
}
|
|
413
419
|
return "";
|
|
414
420
|
|
|
415
421
|
case "ExportAllDeclaration": {
|
|
416
422
|
const exported = node.exported ? ` as ${print(node.exported)}` : "";
|
|
417
|
-
|
|
423
|
+
const typeKind = node.exportKind === "type" ? "type " : "";
|
|
424
|
+
return `export ${typeKind}*${exported} from ${print(node.source)};`;
|
|
418
425
|
}
|
|
419
426
|
|
|
420
427
|
case "ExportSpecifier": {
|
|
421
428
|
const local = print(node.local);
|
|
422
429
|
const exported = print(node.exported);
|
|
423
|
-
|
|
430
|
+
const spec = local === exported ? local : `${local} as ${exported}`;
|
|
431
|
+
// Inline `export { type Foo }` modifier.
|
|
432
|
+
return node.exportKind === "type" ? `type ${spec}` : spec;
|
|
424
433
|
}
|
|
425
434
|
|
|
426
435
|
// ── JSX (unsupported — Ember uses Glimmer templates) ─────────
|
|
@@ -532,6 +541,9 @@ export function print(node) {
|
|
|
532
541
|
case "TSArrayType":
|
|
533
542
|
return `${print(node.elementType)}[]`;
|
|
534
543
|
|
|
544
|
+
case "TSParenthesizedType":
|
|
545
|
+
return `(${print(node.typeAnnotation)})`;
|
|
546
|
+
|
|
535
547
|
case "TSTupleType": {
|
|
536
548
|
const elems = (node.elementTypes ?? []).map(print).join(", ");
|
|
537
549
|
return `[${elems}]`;
|