@ripple-ts/prettier-plugin 0.3.5 → 0.3.7

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": "@ripple-ts/prettier-plugin",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Ripple plugin for Prettier",
5
5
  "type": "module",
6
6
  "module": "src/index.js",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "^24.3.0",
28
28
  "prettier": "^3.8.1",
29
- "ripple": "0.3.5"
29
+ "ripple": "0.3.7"
30
30
  },
31
31
  "dependencies": {},
32
32
  "files": [
package/src/index.js CHANGED
@@ -2076,6 +2076,10 @@ function printRippleNode(node, path, options, print, args) {
2076
2076
  nodeContent = printTSMethodSignature(node, path, options, print);
2077
2077
  break;
2078
2078
 
2079
+ case 'TSCallSignatureDeclaration':
2080
+ nodeContent = printTSCallSignatureDeclaration(node, path, options, print);
2081
+ break;
2082
+
2079
2083
  case 'TSEnumMember':
2080
2084
  nodeContent = printTSEnumMember(node, path, options, print);
2081
2085
  break;
@@ -2154,6 +2158,9 @@ function printRippleNode(node, path, options, print, args) {
2154
2158
  case 'TSConditionalType':
2155
2159
  nodeContent = printTSConditionalType(node, path, options, print);
2156
2160
  break;
2161
+ case 'TSInferType':
2162
+ nodeContent = ['infer ', path.call(print, 'typeParameter')];
2163
+ break;
2157
2164
 
2158
2165
  case 'TSMappedType':
2159
2166
  nodeContent = printTSMappedType(node, path, options, print);
@@ -5179,6 +5186,46 @@ function printTSMethodSignature(node, path, options, print) {
5179
5186
  return parts;
5180
5187
  }
5181
5188
 
5189
+ /**
5190
+ * Print a TypeScript call signature in an interface
5191
+ * @param {AST.TSCallSignatureDeclaration} node - The call signature node
5192
+ * @param {AstPath<AST.TSCallSignatureDeclaration>} path - The AST path
5193
+ * @param {RippleFormatOptions} options - Prettier options
5194
+ * @param {PrintFn} print - Print callback
5195
+ * @returns {Doc[]}
5196
+ */
5197
+ function printTSCallSignatureDeclaration(node, path, options, print) {
5198
+ /** @type {Doc[]} */
5199
+ const parts = [];
5200
+
5201
+ // Add TypeScript generics/type parameters if present
5202
+ if (node.typeParameters) {
5203
+ const type_params = path.call(print, 'typeParameters');
5204
+ if (Array.isArray(type_params)) {
5205
+ parts.push(...type_params);
5206
+ } else {
5207
+ parts.push(type_params);
5208
+ }
5209
+ }
5210
+
5211
+ parts.push('(');
5212
+ if (node.parameters && node.parameters.length > 0) {
5213
+ const params = path.map(print, 'parameters');
5214
+ for (let i = 0; i < params.length; i++) {
5215
+ if (i > 0) parts.push(', ');
5216
+ parts.push(params[i]);
5217
+ }
5218
+ }
5219
+ parts.push(')');
5220
+
5221
+ if (node.typeAnnotation) {
5222
+ parts.push(': ');
5223
+ parts.push(path.call(print, 'typeAnnotation'));
5224
+ }
5225
+
5226
+ return parts;
5227
+ }
5228
+
5182
5229
  /**
5183
5230
  * Print a TypeScript type reference (e.g., Array<string>)
5184
5231
  * @param {AST.TSTypeReference} node - The type reference node
package/src/index.test.js CHANGED
@@ -3254,6 +3254,14 @@ const items = [] as unknown[];`;
3254
3254
  expect(result).toBeWithNewline(expected);
3255
3255
  });
3256
3256
 
3257
+ it('should preserve TSCallSignatureDeclaration with conditional types', async () => {
3258
+ const expected = `interface TrackedCallable<V> {
3259
+ (props: V extends Component<infer P> ? P : never): V extends Component ? void : never;
3260
+ }`;
3261
+ const result = await format(expected, { printWidth: 100 });
3262
+ expect(result).toBeWithNewline(expected);
3263
+ });
3264
+
3257
3265
  it('should format TSNonNullExpression', async () => {
3258
3266
  const input = `component Test(){let value:string|null=null;let length=value!.length;<div>{length}</div>}`;
3259
3267
  const expected = `component Test() {