@tsrx/prettier-plugin 0.3.33 → 0.3.35
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 +4 -4
- package/src/index.js +29 -0
- package/src/index.test.js +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/prettier-plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.35",
|
|
4
4
|
"description": "Ripple plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^24.3.0",
|
|
28
28
|
"prettier": "^3.8.3",
|
|
29
|
-
"ripple": "0.3.
|
|
29
|
+
"ripple": "0.3.35"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tsrx/core": "0.0.
|
|
33
|
-
"@tsrx/ripple": "0.0.
|
|
32
|
+
"@tsrx/core": "0.0.15",
|
|
33
|
+
"@tsrx/ripple": "0.0.17"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"src/"
|
package/src/index.js
CHANGED
|
@@ -2117,6 +2117,18 @@ function printRippleNode(node, path, options, print, args) {
|
|
|
2117
2117
|
nodeContent = printTSTupleType(node, path, options, print);
|
|
2118
2118
|
break;
|
|
2119
2119
|
|
|
2120
|
+
case 'TSNamedTupleMember':
|
|
2121
|
+
nodeContent = printTSNamedTupleMember(node, path, options, print);
|
|
2122
|
+
break;
|
|
2123
|
+
|
|
2124
|
+
case 'TSRestType':
|
|
2125
|
+
nodeContent = ['...', path.call(print, 'typeAnnotation')];
|
|
2126
|
+
break;
|
|
2127
|
+
|
|
2128
|
+
case 'TSOptionalType':
|
|
2129
|
+
nodeContent = [path.call(print, 'typeAnnotation'), '?'];
|
|
2130
|
+
break;
|
|
2131
|
+
|
|
2120
2132
|
case 'TSIndexSignature':
|
|
2121
2133
|
nodeContent = printTSIndexSignature(node, path, options, print);
|
|
2122
2134
|
break;
|
|
@@ -5262,6 +5274,23 @@ function printTSTupleType(node, path, options, print) {
|
|
|
5262
5274
|
return parts;
|
|
5263
5275
|
}
|
|
5264
5276
|
|
|
5277
|
+
/**
|
|
5278
|
+
* Print a TypeScript named tuple member
|
|
5279
|
+
* @param {AST.TSNamedTupleMember} node - The named tuple member node
|
|
5280
|
+
* @param {AstPath<AST.TSNamedTupleMember>} path - The AST path
|
|
5281
|
+
* @param {RippleFormatOptions} options - Prettier options
|
|
5282
|
+
* @param {PrintFn} print - Print callback
|
|
5283
|
+
* @returns {Doc[]}
|
|
5284
|
+
*/
|
|
5285
|
+
function printTSNamedTupleMember(node, path, options, print) {
|
|
5286
|
+
return [
|
|
5287
|
+
path.call(print, 'label'),
|
|
5288
|
+
node.optional ? '?' : '',
|
|
5289
|
+
': ',
|
|
5290
|
+
path.call(print, 'elementType'),
|
|
5291
|
+
];
|
|
5292
|
+
}
|
|
5293
|
+
|
|
5265
5294
|
/**
|
|
5266
5295
|
* Print a TypeScript index signature
|
|
5267
5296
|
* @param {AST.TSIndexSignature} node - The index signature node
|
package/src/index.test.js
CHANGED
|
@@ -3298,6 +3298,13 @@ const items = [] as unknown[];`;
|
|
|
3298
3298
|
expect(result).toBeWithNewline(expected);
|
|
3299
3299
|
});
|
|
3300
3300
|
|
|
3301
|
+
it('should preserve named optional TypeScript tuple members', async () => {
|
|
3302
|
+
const input = `export type OptionalTuple = [bar: string, baz?: string];`;
|
|
3303
|
+
const expected = `export type OptionalTuple = [bar: string, baz?: string];`;
|
|
3304
|
+
const result = await format(input);
|
|
3305
|
+
expect(result).toBeWithNewline(expected);
|
|
3306
|
+
});
|
|
3307
|
+
|
|
3301
3308
|
it('should format TypeScript index signatures (TSIndexSignature)', async () => {
|
|
3302
3309
|
const input = `interface Dict { [key: string]: number; readonly [id: number]: string }`;
|
|
3303
3310
|
const expected = `interface Dict {\n [key: string]: number;\n readonly [id: number]: string;\n}`;
|