sveld 0.32.4 → 0.32.6
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/lib/ComponentParser.d.ts +36 -0
- package/lib/index.js +648 -644
- package/package.json +1 -1
package/lib/ComponentParser.d.ts
CHANGED
|
@@ -363,6 +363,8 @@ export default class ComponentParser {
|
|
|
363
363
|
private readonly reactive_vars;
|
|
364
364
|
/** Set of all variable declarations found in the component script */
|
|
365
365
|
private readonly vars;
|
|
366
|
+
/** Function declarations in the component script, by name */
|
|
367
|
+
private readonly funcDecls;
|
|
366
368
|
/** Map of component props keyed by prop name */
|
|
367
369
|
private readonly props;
|
|
368
370
|
/** Map of module exports (functions/variables exported from script) keyed by name */
|
|
@@ -604,6 +606,40 @@ export default class ComponentParser {
|
|
|
604
606
|
* Look up JSDoc on a local variable declaration by name.
|
|
605
607
|
*/
|
|
606
608
|
private resolveLocalVarJSDoc;
|
|
609
|
+
/**
|
|
610
|
+
* Build a function type from `@param`/`@returns` when `@type` is missing.
|
|
611
|
+
* If JSDoc has no params or return either, try the function `node`, then
|
|
612
|
+
* `(...args: any[]) => any`.
|
|
613
|
+
*/
|
|
614
|
+
private buildFunctionTypeFromParts;
|
|
615
|
+
/**
|
|
616
|
+
* Guess arity and return type for a function default with no JSDoc `@type`.
|
|
617
|
+
* Explicit `@type`/`@param`/`@returns` on the prop beat this every time.
|
|
618
|
+
* A default's body is a weak signal for the prop contract. We only read
|
|
619
|
+
* named params and literal returns. Everything else becomes `any`.
|
|
620
|
+
*/
|
|
621
|
+
private inferFunctionTypeFromNode;
|
|
622
|
+
/**
|
|
623
|
+
* Turn params into `name: any`, or use `...args: any[]` when arity is unclear:
|
|
624
|
+
* no params, destructuring, rest, or defaults.
|
|
625
|
+
*/
|
|
626
|
+
private inferParamsFromNode;
|
|
627
|
+
/**
|
|
628
|
+
* Infer return type from literal returns only. Every `return` must agree on
|
|
629
|
+
* the same primitive. Bare `return;`, no returns, identifiers, calls,
|
|
630
|
+
* objects, ternaries, async, or generators all become `any`.
|
|
631
|
+
*/
|
|
632
|
+
private inferReturnTypeFromNode;
|
|
633
|
+
/**
|
|
634
|
+
* Walk a block body and collect each `return`'s argument, skipping nested
|
|
635
|
+
* functions. Bare `return;` becomes `null`.
|
|
636
|
+
*/
|
|
637
|
+
private collectReturnArguments;
|
|
638
|
+
/**
|
|
639
|
+
* Map one return expression to `string`, `number`, or `boolean`, or `null`
|
|
640
|
+
* if it isn't a literal, template literal, or `String`/`Number`/`Boolean` call.
|
|
641
|
+
*/
|
|
642
|
+
private inferReturnPrimitive;
|
|
607
643
|
/**
|
|
608
644
|
* Unwraps `$bindable(...)` calls so defaults are documented as their underlying values.
|
|
609
645
|
*/
|