@alloy-js/typescript 0.14.0 → 0.16.0

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  3. package/dist/src/components/FunctionBase.js +6 -1
  4. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  5. package/dist/src/components/ImportStatement.js +8 -2
  6. package/dist/src/components/MemberExpression.d.ts +21 -4
  7. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  8. package/dist/src/components/MemberExpression.js +302 -88
  9. package/dist/src/components/ObjectExpression.d.ts +6 -0
  10. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  11. package/dist/src/components/ObjectExpression.js +17 -1
  12. package/dist/src/components/index.d.ts +0 -1
  13. package/dist/src/components/index.d.ts.map +1 -1
  14. package/dist/src/components/index.js +0 -1
  15. package/dist/src/components/stc/index.d.ts +0 -1
  16. package/dist/src/components/stc/index.d.ts.map +1 -1
  17. package/dist/src/components/stc/index.js +0 -1
  18. package/dist/src/parameter-descriptor.d.ts +9 -0
  19. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  20. package/dist/test/arrow-function.test.js +17 -0
  21. package/dist/test/basic.test.js +1 -1
  22. package/dist/test/externals.test.js +3 -3
  23. package/dist/test/function-declaration.test.js +18 -0
  24. package/dist/test/function-expression.test.js +17 -0
  25. package/dist/test/function-type.test.js +14 -0
  26. package/dist/test/imports.test.js +114 -4
  27. package/dist/test/member-expression.test.js +285 -5
  28. package/dist/test/object.test.d.ts +2 -0
  29. package/dist/test/object.test.d.ts.map +1 -0
  30. package/dist/test/object.test.js +57 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +3 -3
  33. package/src/components/FunctionBase.tsx +1 -0
  34. package/src/components/ImportStatement.tsx +12 -2
  35. package/src/components/MemberExpression.tsx +364 -103
  36. package/src/components/ObjectExpression.tsx +21 -1
  37. package/src/components/index.ts +0 -1
  38. package/src/components/stc/index.ts +0 -1
  39. package/src/parameter-descriptor.ts +10 -0
  40. package/temp/api.json +231 -94
  41. package/test/arrow-function.test.tsx +22 -0
  42. package/test/basic.test.tsx +1 -1
  43. package/test/externals.test.tsx +3 -3
  44. package/test/function-declaration.test.tsx +22 -0
  45. package/test/function-expression.test.tsx +22 -0
  46. package/test/function-type.test.tsx +17 -0
  47. package/test/imports.test.tsx +75 -4
  48. package/test/member-expression.test.tsx +221 -8
  49. package/test/object.test.tsx +48 -0
  50. package/dist/src/components/MemberChainExpression.d.ts +0 -11
  51. package/dist/src/components/MemberChainExpression.d.ts.map +0 -1
  52. package/dist/src/components/MemberChainExpression.js +0 -98
  53. package/dist/test/member-chain.test.d.ts +0 -2
  54. package/dist/test/member-chain.test.d.ts.map +0 -1
  55. package/dist/test/member-chain.test.js +0 -141
  56. package/src/components/MemberChainExpression.tsx +0 -91
  57. package/test/member-chain.test.tsx +0 -124
@@ -1,4 +1,5 @@
1
1
  import {
2
+ computed,
2
3
  mapJoin,
3
4
  memo,
4
5
  SourceDirectoryContext,
@@ -21,9 +22,15 @@ export interface ImportStatementsProps {
21
22
  export function ImportStatements(props: ImportStatementsProps) {
22
23
  const pkg = usePackage();
23
24
 
25
+ const imports = computed(() =>
26
+ [...props.records].sort(([a], [b]) => {
27
+ return a.name.localeCompare(b.name);
28
+ }),
29
+ );
30
+
24
31
  return mapJoin(
25
- () => props.records,
26
- (module, importedSymbols) => {
32
+ () => imports.value,
33
+ ([module, importedSymbols]) => {
27
34
  let targetPath: string;
28
35
 
29
36
  if (
@@ -91,6 +98,9 @@ export function ImportStatement(props: ImportStatementProps) {
91
98
  }
92
99
 
93
100
  if (namedImportSymbols.length > 0) {
101
+ namedImportSymbols.sort((a, b) => {
102
+ return a.local.name.localeCompare(b.local.name);
103
+ });
94
104
  const allNamedImportsAreTypes = namedImportSymbols.every(
95
105
  (nis) => nis.local.tsFlags & TSSymbolFlags.TypeSymbol,
96
106
  );
@@ -5,12 +5,14 @@ import {
5
5
  For,
6
6
  isComponentCreator,
7
7
  OutputSymbol,
8
- Ref,
8
+ reactive,
9
9
  ref,
10
10
  Refkey,
11
- toRef,
11
+ Show,
12
+ ToRefs,
12
13
  useBinder,
13
14
  } from "@alloy-js/core";
15
+
14
16
  import { TSOutputSymbol, TSSymbolFlags } from "../symbols/ts-output-symbol.js";
15
17
  import { isValidJSIdentifier } from "../utils.js";
16
18
 
@@ -19,10 +21,11 @@ export interface MemberExpressionProps {
19
21
  }
20
22
 
21
23
  interface PartDescriptor {
22
- base: string | Ref<string>;
23
- accessStyle: Ref<"dot" | "bracket">;
24
- nullish: Ref<boolean>;
25
- args?: Children[] | boolean;
24
+ id: Children;
25
+ accessStyle: "dot" | "bracket";
26
+ quoteId: boolean;
27
+ nullish: boolean;
28
+ args?: Children[];
26
29
  }
27
30
 
28
31
  /**
@@ -30,12 +33,18 @@ interface PartDescriptor {
30
33
  * the following:
31
34
  *
32
35
  * * **id**: The identifier for the member expression part
33
- * * **refkey**: A refkey for a symbol whose name becomes the identifier
36
+ * * **refkey**: a refkey for a symbol whose name becomes the identifier
34
37
  * * **symbol**: a symbol whose name becomes the identifier part
35
38
  * * **args**: create a method call with the given args
39
+ * * **children**: arbitrary contents for the identifier part.
40
+ *
41
+ * Each part can have a nullish prop, which indicates that the part may be null
42
+ * or undefined.
36
43
  *
37
- * Additionally, a part can be `nullish`, which means subsequent parts
38
- * will use the appropriate conditional access operator e.g. `?.`.
44
+ * Each part can also have a quoteId prop, which indicates that the identifier
45
+ * of the part should be quoted (i.e. `["foo"]` instead of `.foo`). This is only
46
+ * necessary when providing the children prop, otherwise it is determined
47
+ * automatically.
39
48
  *
40
49
  * @example
41
50
  *
@@ -45,6 +54,7 @@ interface PartDescriptor {
45
54
  * <MemberExpression.Part refkey={rk} nullish />
46
55
  * <MemberExpression.Part symbol={sym} />
47
56
  * <MemberExpression.Part args={["hello", "world"]} />
57
+ * <MemberExpression.Part>SomeValue</MemberExpression.Part>
48
58
  * </MemberExpression>
49
59
  * ```
50
60
  *
@@ -52,11 +62,41 @@ interface PartDescriptor {
52
62
  * with a name of "prop2", this will render:
53
63
  *
54
64
  * ```ts
55
- * base.prop1?.prop2("hello", "world")
65
+ * base.prop1?.prop2("hello", "world").SomeValue
56
66
  * ```
57
67
  */
58
68
  export function MemberExpression(props: MemberExpressionProps): Children {
59
69
  const children = flattenMemberExpression(childrenArray(() => props.children));
70
+ const parts = childrenToPartDescriptors(children);
71
+
72
+ if (parts.length === 0) {
73
+ return <></>;
74
+ }
75
+
76
+ const isCallChain = computed(() => {
77
+ let callCount = 0;
78
+ for (const part of parts) {
79
+ if (part.args !== undefined) callCount++;
80
+ }
81
+
82
+ return callCount > 1;
83
+ });
84
+
85
+ // construct a member expression from the parts. When a part is nullish,
86
+ // and there is a subsequent part, we use `?.` instead of `.`. accessStyle determines
87
+ // whether we use dot or bracket notation.
88
+
89
+ return computed(() => {
90
+ return isCallChain.value ?
91
+ formatCallChain(parts)
92
+ : formatNonCallChain(parts);
93
+ });
94
+ }
95
+
96
+ /**
97
+ * Build part descriptors from the children of a MemberExpression.
98
+ */
99
+ function childrenToPartDescriptors(children: Children[]): PartDescriptor[] {
60
100
  const parts: PartDescriptor[] = [];
61
101
  for (const child of children) {
62
102
  if (!isComponentCreator(child, MemberExpression.Part)) {
@@ -64,121 +104,320 @@ export function MemberExpression(props: MemberExpressionProps): Children {
64
104
  continue;
65
105
  }
66
106
 
67
- const partProps = child.props;
68
- const part: PartDescriptor = {
69
- base: "",
70
- accessStyle: ref("dot"),
71
- nullish: ref(!!partProps.nullish),
72
- };
73
-
74
- if (partProps.id) {
75
- part.base = partProps.id;
76
- part.accessStyle.value = accessStyleForMemberName(partProps.id);
77
- } else if (partProps.refkey) {
78
- const binder = useBinder();
79
- const symbolRef = binder.getSymbolForRefkey(partProps.refkey);
80
- part.base = computed(() => {
81
- if (symbolRef.value) {
82
- part.nullish.value = !!(
83
- (symbolRef.value as TSOutputSymbol).tsFlags & TSSymbolFlags.Nullish
84
- );
85
- part.accessStyle.value = accessStyleForMemberName(
86
- symbolRef.value.name,
87
- );
88
- return symbolRef.value.name;
89
- } else {
90
- return "<unresolved symbol>";
91
- }
92
- });
107
+ parts.push(
108
+ createPartDescriptorFromProps(child.props, child === children[0]),
109
+ );
110
+ }
111
+
112
+ return parts;
113
+ }
114
+
115
+ const exclusiveParts: (keyof MemberExpressionPartProps)[] = [
116
+ "children",
117
+ "args",
118
+ "refkey",
119
+ "symbol",
120
+ "id",
121
+ ];
122
+ /**
123
+ * Creates a reactive part descriptor from the given part props.
124
+ *
125
+ * @param partProps The props for the part.
126
+ * @param first Whether this is the first part in the expression. Refkeys are
127
+ * handled specially for the first part.
128
+ */
129
+ function createPartDescriptorFromProps(
130
+ partProps: MemberExpressionPartProps,
131
+ first: boolean,
132
+ ) {
133
+ const foundProps = exclusiveParts.filter((key) => {
134
+ return key in partProps;
135
+ });
136
+
137
+ if (foundProps.length > 1) {
138
+ throw new Error(
139
+ `Only one of ${foundProps.join(", ")} can be used for a MemberExpression part at a time`,
140
+ );
141
+ }
142
+
143
+ const symbolSource = computed(() => {
144
+ if (partProps.refkey) {
145
+ return getSymbolForRefkey(partProps.refkey).value;
93
146
  } else if (partProps.symbol) {
94
- part.nullish.value = !!(
95
- (partProps.symbol as TSOutputSymbol).tsFlags & TSSymbolFlags.Nullish
96
- );
97
- part.accessStyle = computed(() => {
98
- return accessStyleForMemberName(partProps.symbol!.name);
99
- });
100
- part.base = toRef(partProps.symbol, "name");
101
- } else if (partProps.args) {
102
- part.args = partProps.args;
147
+ return partProps.symbol;
148
+ } else {
149
+ return undefined;
103
150
  }
151
+ });
104
152
 
105
- parts.push(part);
106
- }
153
+ const part: ToRefs<PartDescriptor> = {
154
+ id: computed(() => {
155
+ if (partProps.args) {
156
+ return undefined;
157
+ } else if ("children" in partProps && partProps.children !== undefined) {
158
+ return partProps.children;
159
+ } else if (first && partProps.refkey) {
160
+ return partProps.refkey;
161
+ } else if (partProps.id) {
162
+ return escapeId(partProps.id);
163
+ } else if (symbolSource.value) {
164
+ return escapeId(symbolSource.value.name);
165
+ } else {
166
+ return "<unresolved symbol>";
167
+ }
168
+ }),
169
+ accessStyle: computed(() => {
170
+ if (partProps.args) {
171
+ // not used
172
+ return "dot";
173
+ } else if (partProps.quoteId) {
174
+ return "bracket";
175
+ } else if (partProps.id) {
176
+ return accessStyleForMemberName(partProps.id);
177
+ } else if (symbolSource.value) {
178
+ return accessStyleForMemberName(symbolSource.value.name);
179
+ } else {
180
+ return "dot";
181
+ }
182
+ }),
183
+ quoteId: computed(() => {
184
+ if (partProps.quoteId) {
185
+ return partProps.quoteId;
186
+ } else if (partProps.id) {
187
+ return !isValidJSIdentifier(partProps.id);
188
+ } else if (symbolSource.value) {
189
+ return !isValidJSIdentifier(symbolSource.value.name);
190
+ } else {
191
+ return false;
192
+ }
193
+ }),
194
+ nullish: computed(() => {
195
+ if (partProps.nullish) {
196
+ return partProps.nullish;
197
+ }
107
198
 
108
- if (parts.length === 0) {
109
- return <></>;
110
- }
199
+ if (symbolSource.value) {
200
+ return isNullish(symbolSource.value);
201
+ }
111
202
 
112
- // construct a member expression from the parts. When a part is nullish,
113
- // and there is a subsequent part, we use `?.` instead of `.`. accessStyle determines
114
- // whether we use dot or bracket notation.
203
+ return false;
204
+ }),
205
+ args: ref<any>(partProps.args === true ? [] : partProps.args),
206
+ };
115
207
 
116
- const result = computed(() => {
208
+ return reactive(part);
209
+ }
210
+
211
+ /**
212
+ * replaces quotes with escaped quotes
213
+ */
214
+ function escapeId(id: string) {
215
+ return id.replace(/"/g, '\\"');
216
+ }
217
+
218
+ /**
219
+ * Convert a refkey to a symbol ref using the current binder.
220
+ */
221
+ function getSymbolForRefkey(refkey: Refkey) {
222
+ const binder = useBinder();
223
+ return binder.getSymbolForRefkey(refkey);
224
+ }
225
+
226
+ /**
227
+ * Check if the given symbol is nullish.
228
+ */
229
+ function isNullish(symbol: OutputSymbol): boolean {
230
+ return !!((symbol as TSOutputSymbol).tsFlags & TSSymbolFlags.Nullish);
231
+ }
232
+
233
+ /**
234
+ * Formatting of call chains (i.e. member expressions which have more than one
235
+ * call in them). The general approach is that line breaks occur after each
236
+ * call, and there is only one call per line. When there are non-call elements,
237
+ * they occur prior to the call part. The first part of the member expression
238
+ * contains all but the last non-call part.
239
+ *
240
+ * The following is an example of proper formatting:
241
+ *
242
+ * ```ts
243
+ * z.dummy // all but the last non-call part for the first element
244
+ * .object({ // the first call part with line break after
245
+ * a: 1,
246
+ * })
247
+ * .dummy.partial() // the next call part with non-call parts before it
248
+ * ```
249
+ */
250
+ function formatCallChain(parts: PartDescriptor[]): Children {
251
+ return computed(() => {
252
+ const expression: Children[] = [];
253
+
254
+ // break the expression into parts.
255
+ const chunks: PartDescriptor[][] = [];
256
+
257
+ // the first part is all the non-call parts
258
+ let partIndex = 0;
259
+
260
+ function pushPart() {
261
+ const part = parts[partIndex];
262
+ if (!part) throw new Error("No part to push");
263
+ chunks.at(-1)!.push(part);
264
+ partIndex++;
265
+ }
266
+
267
+ function pushChunk() {
268
+ chunks.push([]);
269
+ }
270
+
271
+ // For the first chunk, take all the non-call parts except the last one
272
+ // and put them in a chunk.
273
+ pushChunk();
274
+ while (
275
+ partIndex < parts.length &&
276
+ (partIndex === parts.length - 1 ||
277
+ chunks.at(-1)!.length === 0 ||
278
+ parts[partIndex + 1].args === undefined)
279
+ ) {
280
+ pushPart();
281
+ if (chunks.at(-1)!.at(-1)!.args !== undefined) {
282
+ // the first segment always ends after we see a call
283
+ // if we happen to take one
284
+ break;
285
+ }
286
+ }
287
+
288
+ // then for all remaining parts, collect all the non-call parts and end with
289
+ // a call chunk
290
+ while (partIndex < parts.length) {
291
+ pushChunk();
292
+ while (partIndex < parts.length && !parts[partIndex].args) {
293
+ pushPart();
294
+ }
295
+ while (partIndex < parts.length && parts[partIndex].args) {
296
+ pushPart();
297
+ }
298
+ }
299
+
300
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
301
+ const chunk = chunks[chunkIndex];
302
+ const chunkExpression = [];
303
+ for (let partIndex = 0; partIndex < chunk.length; partIndex++) {
304
+ if (chunkIndex === 0 && partIndex === 0) {
305
+ // first part is just gonna be the id
306
+ chunkExpression.push(chunk[0].id);
307
+ continue;
308
+ }
309
+ const part = chunk[partIndex];
310
+ const prevPart =
311
+ partIndex === 0 ?
312
+ chunks[chunkIndex - 1].at(-1)!
313
+ : chunk[partIndex - 1];
314
+
315
+ if (part.args !== undefined) {
316
+ // For parts with only args (no name), append function call directly with appropriate nullish operator
317
+ chunkExpression.push(formatCallExpr(prevPart, part));
318
+ } else if (part.accessStyle === "dot") {
319
+ chunkExpression.push(formatDotAccess(prevPart, part));
320
+ } else {
321
+ // bracket notation - don't include the dot
322
+ chunkExpression.push(formatArrayAccess(prevPart, part));
323
+ }
324
+ }
325
+
326
+ expression.push(
327
+ chunkIndex === 0 ? chunkExpression : (
328
+ <>
329
+ <sbr />
330
+ {chunkExpression}
331
+ </>
332
+ ),
333
+ );
334
+ }
335
+
336
+ return (
337
+ <group>
338
+ <indent>{expression}</indent>
339
+ </group>
340
+ );
341
+ });
342
+ }
343
+
344
+ function formatNonCallChain(parts: PartDescriptor[]): Children {
345
+ return computed(() => {
117
346
  const expression: Children[] = [];
118
347
 
119
348
  for (let i = 0; i < parts.length; i++) {
120
349
  const part = parts[i];
121
- const base = typeof part.base === "string" ? part.base : part.base.value;
122
- const hasName = base !== "";
123
-
350
+ const base = part.id;
124
351
  if (i === 0) {
125
352
  expression.push(base);
126
353
  } else {
127
354
  // Determine if we should use nullish operator from previous part
128
355
  const prevPart = parts[i - 1];
129
- const isNullish = prevPart.nullish.value;
130
-
131
- // Handle parts with name vs. parts with only args differently
132
- if (hasName) {
133
- // Apply dot or bracket notation based on accessStyle for named parts
134
- if (part.accessStyle.value === "dot") {
135
- expression.push(
136
- <group>
137
- <indent>
138
- <sbr />
139
- {isNullish ? "?." : "."}
140
- {base}
141
- </indent>
142
- </group>,
143
- );
144
- } else {
145
- // bracket notation - don't include the dot
146
- expression.push(
147
- <group>
148
- {isNullish ? "?." : ""}[
149
- <indent>
150
- <sbr />
151
- {JSON.stringify(base)}
152
- </indent>
153
- <sbr />]
154
- </group>,
155
- );
156
- }
157
- } else if (part.args !== undefined) {
356
+
357
+ if (part.args !== undefined) {
158
358
  // For parts with only args (no name), append function call directly with appropriate nullish operator
159
- expression.push(
160
- <group>
161
- {isNullish ? "?." : ""}
162
- <group>
163
- (
164
- <For
165
- each={typeof part.args === "boolean" ? [] : (part.args ?? [])}
166
- comma
167
- line
168
- >
169
- {(arg) => arg}
170
- </For>
171
- )
172
- </group>
173
- </group>,
174
- );
359
+ expression.push(formatCallExpr(prevPart, part));
360
+ } else if (part.accessStyle === "dot") {
361
+ expression.push(formatDotAccess(prevPart, part));
362
+ } else {
363
+ // bracket notation - don't include the dot
364
+ expression.push(formatArrayAccess(prevPart, part));
175
365
  }
176
366
  }
177
367
  }
178
368
 
179
369
  return expression;
180
370
  });
181
- return <>{result.value}</>;
371
+ }
372
+
373
+ function formatArrayAccess(prevPart: PartDescriptor, part: PartDescriptor) {
374
+ return (
375
+ <group>
376
+ {prevPart.nullish ? "?." : ""}[
377
+ <indent>
378
+ <sbr />
379
+ {part.quoteId && '"'}
380
+ {part.id}
381
+ {part.quoteId && '"'}
382
+ </indent>
383
+ <sbr />]
384
+ </group>
385
+ );
386
+ }
387
+
388
+ function formatDotAccess(prevPart: PartDescriptor, part: PartDescriptor) {
389
+ return (
390
+ <group>
391
+ <indent>
392
+ <sbr />
393
+ {prevPart.nullish ? "?." : "."}
394
+ {part.id}
395
+ </indent>
396
+ </group>
397
+ );
398
+ }
399
+
400
+ function formatCallExpr(prevPart: PartDescriptor, part: PartDescriptor) {
401
+ const args = computed(() => {
402
+ return typeof part.args === "boolean" ? [] : (part.args ?? []);
403
+ });
404
+
405
+ return (
406
+ <group>
407
+ {prevPart.nullish ? "?." : ""}(
408
+ <Show when={args.value.length <= 1}>{args.value[0]}</Show>
409
+ <Show when={args.value.length > 1}>
410
+ <indent>
411
+ <sbr />
412
+ <For each={args} comma line>
413
+ {(arg) => arg}
414
+ </For>
415
+ </indent>
416
+ <sbr />
417
+ </Show>
418
+ )
419
+ </group>
420
+ );
182
421
  }
183
422
 
184
423
  function accessStyleForMemberName(name: string) {
@@ -207,6 +446,13 @@ export interface MemberExpressionPartProps {
207
446
  * The identifier for this part of the member expression.
208
447
  */
209
448
  id?: string;
449
+
450
+ /**
451
+ * Whether the identifier should be quoted or not. Only needed when
452
+ * providing the `children` prop, otherwise it is determined automatically.
453
+ */
454
+ quoteId?: boolean;
455
+
210
456
  /**
211
457
  * A refkey for a symbol whose name becomes the identifier.
212
458
  */
@@ -224,6 +470,12 @@ export interface MemberExpressionPartProps {
224
470
  * This part is nullish. Subsequent parts use conditional access operators.
225
471
  */
226
472
  nullish?: boolean;
473
+
474
+ /**
475
+ * The contents of this part. When passed, overrides the other props except
476
+ * nullish.
477
+ */
478
+ children?: Children;
227
479
  }
228
480
  /**
229
481
  * A part of a member expression. Each part can provide one of the following
@@ -233,6 +485,15 @@ export interface MemberExpressionPartProps {
233
485
  * * **refkey**: A refkey for a symbol whose name becomes the identifier
234
486
  * * **symbol**: a symbol whose name becomes the identifier part
235
487
  * * **args**: create a method call with the given args
488
+ * * **children**: arbitrary contents for the identifier part.
489
+ *
490
+ * Each part can have a nullish prop, which indicates that the part may be null
491
+ * or undefined.
492
+ *
493
+ * Each part can also have a quoteId prop, which indicates that the identifier
494
+ * of the part should be quoted (i.e. `["foo"]` instead of `.foo`). This is only
495
+ * necessary when providing the children prop, otherwise it is determined
496
+ * automatically.
236
497
  */
237
498
  MemberExpression.Part = function (props: MemberExpressionPartProps) {
238
499
  /**
@@ -120,7 +120,7 @@ export function ObjectProperty(props: ObjectPropertyProps) {
120
120
  let value;
121
121
  if (props.value) {
122
122
  value = props.value;
123
- } else if (Object.prototype.hasOwnProperty.call(props, "jsValue")) {
123
+ } else if (Object.hasOwn(props, "jsValue")) {
124
124
  // need the hasOwnProperty check because the value might be falsy.
125
125
  value = <ValueExpression jsValue={props.jsValue} />;
126
126
  } else if (props.children) {
@@ -138,3 +138,23 @@ export function ObjectProperty(props: ObjectPropertyProps) {
138
138
  </>
139
139
  );
140
140
  }
141
+
142
+ export interface ObjectSpreadPropertyProps {
143
+ value?: Children;
144
+ jsValue?: unknown;
145
+ children?: Children;
146
+ }
147
+
148
+ export function ObjectSpreadProperty(props: ObjectSpreadPropertyProps) {
149
+ let value;
150
+ if (props.value) {
151
+ value = props.value;
152
+ } else if (Object.hasOwn(props, "jsValue")) {
153
+ // need the hasOwnProperty check because the value might be falsy.
154
+ value = <ValueExpression jsValue={props.jsValue} />;
155
+ } else if (props.children) {
156
+ value = props.children;
157
+ }
158
+
159
+ return <>...{value}</>;
160
+ }
@@ -26,7 +26,6 @@ export * from "./InterfaceMethod.jsx";
26
26
  export * from "./JSDoc.jsx";
27
27
  export * from "./JSDocComment.jsx";
28
28
  export * from "./JSDocExample.jsx";
29
- export * from "./MemberChainExpression.jsx";
30
29
  export * from "./MemberExpression.jsx";
31
30
  export * from "./ObjectExpression.js";
32
31
  export * from "./PackageDirectory.js";
@@ -30,7 +30,6 @@ export const JSDoc = stc(base.JSDoc);
30
30
  export const JSDocExample = stc(base.JSDocExample);
31
31
  export const JSDocComment = stc(base.JSDocComment);
32
32
  export const MemberExpression = stc(base.MemberExpression);
33
- export const MemberChainExpression = stc(base.MemberChainExpression);
34
33
  export const ObjectExpression = stc(base.ObjectExpression);
35
34
  export const ObjectProperty = stc(base.ObjectProperty);
36
35
  export const PackageDirectory = stc(base.PackageDirectory);
@@ -24,6 +24,16 @@ export interface ParameterDescriptorBase {
24
24
  */
25
25
  readonly optional?: boolean;
26
26
 
27
+ /**
28
+ * Weather the parameter is rest parameter.
29
+ * @example
30
+ *
31
+ * ```ts
32
+ * ...args: string[]
33
+ * ```
34
+ */
35
+ readonly rest?: boolean;
36
+
27
37
  /**
28
38
  * Whether the parameter is can be null or undefined.
29
39
  * when optional is true, this will be set to true by default,