sveld 0.24.9 → 0.25.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.
@@ -193,6 +193,7 @@ class ComponentParser {
193
193
  let currentTypedefName;
194
194
  let currentTypedefType;
195
195
  let currentTypedefDescription;
196
+ let commentDescriptionUsed = false;
196
197
  const typedefProperties = [];
197
198
  const finalizeEvent = () => {
198
199
  if (currentEventName !== undefined) {
@@ -309,10 +310,18 @@ class ComponentParser {
309
310
  // Start tracking new typedef
310
311
  currentTypedefName = name;
311
312
  currentTypedefType = type;
312
- // Use inline description if present, otherwise use comment description
313
+ // Use inline description if present, otherwise use comment description only if not already used
313
314
  const trimmedCommentDesc = commentDescription?.trim();
314
- currentTypedefDescription =
315
- description || (trimmedCommentDesc && trimmedCommentDesc !== "}" ? trimmedCommentDesc : undefined);
315
+ if (description) {
316
+ currentTypedefDescription = description;
317
+ }
318
+ else if (!commentDescriptionUsed && trimmedCommentDesc && trimmedCommentDesc !== "}") {
319
+ currentTypedefDescription = trimmedCommentDesc;
320
+ commentDescriptionUsed = true;
321
+ }
322
+ else {
323
+ currentTypedefDescription = undefined;
324
+ }
316
325
  break;
317
326
  }
318
327
  case "generics":
@@ -26,7 +26,14 @@ function formatTsProps(props) {
26
26
  function getTypeDefs(def) {
27
27
  if (def.typedefs.length === 0)
28
28
  return EMPTY_STR;
29
- return def.typedefs.map((typedef) => `export ${typedef.ts}`).join("\n\n");
29
+ return def.typedefs
30
+ .map((typedef) => {
31
+ const typedefComment = typedef.description
32
+ ? `/**\n * ${typedef.description.replace(NEWLINE_TO_COMMENT_REGEX, "\n * ")}\n */\n`
33
+ : "";
34
+ return `${typedefComment}export ${typedef.ts}`;
35
+ })
36
+ .join("\n\n");
30
37
  }
31
38
  function getContextDefs(def) {
32
39
  if (!def.contexts || def.contexts.length === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveld",
3
- "version": "0.24.9",
3
+ "version": "0.25.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Generate TypeScript definitions for your Svelte components.",
6
6
  "main": "./lib/index.js",