@tsrx/prettier-plugin 0.3.99 → 0.3.100

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsrx/prettier-plugin",
3
- "version": "0.3.99",
3
+ "version": "0.3.100",
4
4
  "description": "Ripple plugin for Prettier",
5
5
  "type": "module",
6
6
  "module": "src/index.js",
@@ -27,7 +27,7 @@
27
27
  "prettier": "^3.8.4"
28
28
  },
29
29
  "dependencies": {
30
- "@tsrx/core": "0.1.41"
30
+ "@tsrx/core": "0.1.42"
31
31
  },
32
32
  "files": [
33
33
  "src/"
package/src/index.js CHANGED
@@ -2048,6 +2048,7 @@ function printRippleNode(node, path, options, print, args) {
2048
2048
 
2049
2049
  case 'TSModuleDeclaration': {
2050
2050
  nodeContent = [
2051
+ node.declare ? 'declare ' : '',
2051
2052
  node.metadata?.module_keyword ?? 'module',
2052
2053
  ' ',
2053
2054
  path.call(print, 'id'),
@@ -2598,16 +2599,17 @@ function printExportNamedDeclaration(node, path, options, print) {
2598
2599
  return parts;
2599
2600
  } else if (node.specifiers && node.specifiers.length > 0) {
2600
2601
  const specifiers = node.specifiers.map((spec) => {
2602
+ const typePrefix = spec.exportKind === 'type' ? 'type ' : '';
2601
2603
  const exportedName = /** @type {AST.Identifier} */ (spec.exported).name;
2602
2604
  const localName = /** @type {AST.Identifier} */ (spec.local).name;
2603
2605
  if (exportedName === localName) {
2604
- return localName;
2606
+ return typePrefix + localName;
2605
2607
  } else {
2606
- return localName + ' as ' + exportedName;
2608
+ return typePrefix + localName + ' as ' + exportedName;
2607
2609
  }
2608
2610
  });
2609
2611
 
2610
- const parts = ['export { '];
2612
+ const parts = [node.exportKind === 'type' ? 'export type { ' : 'export { '];
2611
2613
  for (let i = 0; i < specifiers.length; i++) {
2612
2614
  if (i > 0) parts.push(', ');
2613
2615
  parts.push(specifiers[i]);
@@ -4696,7 +4698,9 @@ function printJSXSwitchCase(node, path, options, print, index) {
4696
4698
  if (!child || child.type === 'EmptyStatement') {
4697
4699
  continue;
4698
4700
  }
4699
- printedConsequents.push(path.call(print, 'cases', index, 'consequent', i));
4701
+ printedConsequents.push(
4702
+ path.call((casePath) => casePath.call(print, 'consequent', i), 'cases', index),
4703
+ );
4700
4704
  }
4701
4705
 
4702
4706
  const bodyDoc =
package/src/index.test.js CHANGED
@@ -1507,6 +1507,36 @@ import { Something, type Props, track } from 'ripple';`;
1507
1507
  expect(result).toBeWithNewline(expected);
1508
1508
  });
1509
1509
 
1510
+ // Regressed in 0.3.97: the printer dropped the `type` keyword from
1511
+ // type-only re-exports and inline export specifiers, turning them into
1512
+ // runtime re-exports of bindings that only exist as types (a module-load
1513
+ // failure once compiled).
1514
+ it('should keep the type keyword on export type statements', async () => {
1515
+ const input = `export type { Config } from './types.js';
1516
+ export { type Extra, realValue } from './mixed.js';`;
1517
+ const expected = `export type { Config } from './types.js';
1518
+ export { type Extra, realValue } from './mixed.js';`;
1519
+ const result = await format(input, { singleQuote: true });
1520
+ expect(result).toBeWithNewline(expected);
1521
+ });
1522
+
1523
+ // Regressed in 0.3.97: `declare module 'name' { … }` lost its `declare`
1524
+ // keyword, leaving invalid `module 'name' { … }` output.
1525
+ it('should keep the declare keyword on ambient module declarations', async () => {
1526
+ const input = `declare module 'some-module' {
1527
+ interface Thing {
1528
+ x: number;
1529
+ }
1530
+ }`;
1531
+ const expected = `declare module 'some-module' {
1532
+ interface Thing {
1533
+ x: number;
1534
+ }
1535
+ }`;
1536
+ const result = await format(input, { singleQuote: true });
1537
+ expect(result).toBeWithNewline(expected);
1538
+ });
1539
+
1510
1540
  it('should format long import statements correctly', async () => {
1511
1541
  const input = `import { flushSync, track, effect, bindValue, bindChecked, bindGroup, bindClientWidth, bindClientHeight, bindOffsetWidth, bindOffsetHeight, bindContentRect, bindContentBoxSize, bindBorderBoxSize, bindDevicePixelContentBoxSize, bindInnerHTML, bindInnerText, bindTextContent, bindNode } from 'ripple';`;
1512
1542
  const expected = `import {