sveld 0.25.2 → 0.25.4

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/README.md CHANGED
@@ -332,6 +332,13 @@ export let kind = "primary";
332
332
  // inferred type: "string"
333
333
  ```
334
334
 
335
+ For template literal default values, `sveld` infers the type as `string`:
336
+
337
+ ```js
338
+ export let id = `ccs-${Math.random().toString(36)}`;
339
+ // inferred type: "string"
340
+ ```
341
+
335
342
  Use the `@type` tag to explicitly document the type. In the following example, the `kind` property has an enumerated (enum) type.
336
343
 
337
344
  Signature:
@@ -835,6 +835,11 @@ class ComponentParser {
835
835
  }
836
836
  // Otherwise, don't infer type, just preserve existing type annotation.
837
837
  }
838
+ else if (init.type === "TemplateLiteral") {
839
+ // Handle template literals - they always evaluate to strings
840
+ value = this.sourceAtPos(init.start, init.end);
841
+ type = "string";
842
+ }
838
843
  else {
839
844
  value = init.raw;
840
845
  type = init.value == null ? undefined : typeof init.value;
@@ -1023,6 +1028,11 @@ class ComponentParser {
1023
1028
  }
1024
1029
  // Otherwise, don't infer type, just preserve existing type annotation.
1025
1030
  }
1031
+ else if (init.type === "TemplateLiteral") {
1032
+ // Handle template literals - they always evaluate to strings
1033
+ value = this.sourceAtPos(init.start, init.end);
1034
+ type = "string";
1035
+ }
1026
1036
  else {
1027
1037
  value = init.raw;
1028
1038
  type = init.value == null ? undefined : typeof init.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveld",
3
- "version": "0.25.2",
3
+ "version": "0.25.4",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Generate TypeScript definitions for your Svelte components.",
6
6
  "main": "./lib/index.js",