sveld 0.37.3 → 0.37.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 +14 -2
- package/lib/browser.d.ts +32 -4
- package/lib/browser.js +150 -136
- package/lib/chunk-49hdrj4n.js +6 -0
- package/lib/chunk-7e36grhy.js +1 -0
- package/lib/{chunk-m2bfvdte.js → chunk-nxa0q3f3.js} +5 -5
- package/lib/chunk-rftengvg.js +331 -0
- package/lib/chunk-w37f2cq2.js +1 -0
- package/lib/{chunk-s4f6b34h.js → chunk-yzb9k33r.js} +1 -1
- package/lib/cli-entry.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/schema/component-api.schema.json +20 -1
- package/lib/chunk-ag202nwj.js +0 -317
- package/lib/chunk-n14td14g.js +0 -1
- package/lib/chunk-te52wx32.js +0 -1
- package/lib/chunk-v4be4g6y.js +0 -6
package/README.md
CHANGED
|
@@ -435,7 +435,8 @@ Every diagnostic carries a stable, namespaced `code` (`"sveld/<kind>"`) alongsid
|
|
|
435
435
|
| `sveld/rest-props-unresolved` | `warning` | Spread `$$restProps` onto a plain element (or `svelte:element`) instead of a component, or add an `@restProps` tag to type it manually. |
|
|
436
436
|
| `sveld/context-duplicate-key` | `warning` | Remove the duplicate `setContext` call, or give it a distinct key; only the first call's shape is used. |
|
|
437
437
|
| `sveld/spread-unresolved` | `warning` | Spread a local object literal or a variable with a resolvable type instead; otherwise the spread widens the generated type to `Record<string, any>`. |
|
|
438
|
-
| `sveld/export-unresolved` | `warning` | Export a local declaration directly
|
|
438
|
+
| `sveld/export-unresolved` | `warning` | Export a local declaration directly. Instance-script exports are props, so move a re-export (`export { x } from "..."`, or `export { x }` of an import) into `<script context="module">`, where sveld writes it to the `.d.ts` as-is. |
|
|
439
|
+
| `sveld/module-export-conflict` | `warning` | Rename the module-script export. `default` is always skipped (it collides with the component itself); a name matching the generated `<Name>Props`/`<Name>Exports` type breaks the `.d.ts` if the export carries a type. |
|
|
439
440
|
| `sveld/extend-props-target-missing` | `error` | Point `@extends`/`@extendProps` at a file that exists, and (for a bundled `.svelte` target) name its generated `<Name>Props` interface exactly. |
|
|
440
441
|
| `sveld/extend-props-duplicate` | `warning` | Remove the extra `@extends`/`@extendProps` tag; only the last one is used. |
|
|
441
442
|
| `sveld/extend-props-override` | `warning` | Rename the own prop, or accept that it intentionally overrides the `@extends` target's prop of the same name. |
|
|
@@ -443,13 +444,14 @@ Every diagnostic carries a stable, namespaced `code` (`"sveld/<kind>"`) alongsid
|
|
|
443
444
|
| `sveld/typedef-duplicate` | `warning` | Rename one of the `@typedef`/`@callback` declarations; only the later one is kept. |
|
|
444
445
|
| `sveld/property-duplicate` | `warning` | Remove the duplicate `@property`; only the later one is kept. |
|
|
445
446
|
| `sveld/generics-conflict` | `warning` | Rename one of the `@generics`/`@template` declarations to a distinct generic name. |
|
|
447
|
+
| `sveld/event-description-ambiguous` | `warning` | Put an event's description above its `@event` tag (or indent it as a continuation of the tag's line), or give each event its own comment block. Unindented text after an `@event` is read as the description of the tag below it. |
|
|
446
448
|
| `sveld/jsdoc-tag-dropped` | `warning` | Move the tag next to a `@slot`/`@snippet`/`@event`/`@typedef`/`@callback` tag in the same comment block so it has something to attach to. |
|
|
447
449
|
| `sveld/internal-typedef-referenced` | `error` | Remove `@internal`/`@ignore` from the referenced typedef, or stop referencing it from public type text (inline the shape, or make the referencing item `@internal` too). |
|
|
448
450
|
| `sveld/types-inline-unresolved` | `warning` | The import is kept as-is. Point it at a relative `.ts` file that exports a `type`/`interface`, or rename the colliding type. |
|
|
449
451
|
|
|
450
452
|
#### Severity and `--strict=errors`
|
|
451
453
|
|
|
452
|
-
Each diagnostic's `severity` is `"error"` (`example-compile-error`, `example-syntax-error`, `syntax-skipped`, `extend-props-target-missing`, `internal-typedef-referenced` — sveld emitted broken or unmodeled output) or `"warning"` (`prop-unknown-type`, `context-any-type`, `slot-missing-type`, `event-no-source`, `rest-props-unresolved`, `context-duplicate-key`, `spread-unresolved`, `export-unresolved`, `extend-props-duplicate`, `extend-props-override`, `jsdoc-unknown-tag`, `typedef-duplicate`, `property-duplicate`, `generics-conflict`, `jsdoc-tag-dropped`, `types-inline-unresolved` — a type fell back to `any`). Plain `strict: true` / `--strict` fails on both, unchanged from before. Pass `strict: "errors"` (or `--strict=errors`) to fail CI only on `error`-severity diagnostics, letting `any`-fallback warnings through:
|
|
454
|
+
Each diagnostic's `severity` is `"error"` (`example-compile-error`, `example-syntax-error`, `syntax-skipped`, `extend-props-target-missing`, `internal-typedef-referenced` — sveld emitted broken or unmodeled output) or `"warning"` (`prop-unknown-type`, `context-any-type`, `slot-missing-type`, `event-no-source`, `rest-props-unresolved`, `context-duplicate-key`, `spread-unresolved`, `export-unresolved`, `module-export-conflict`, `extend-props-duplicate`, `extend-props-override`, `jsdoc-unknown-tag`, `typedef-duplicate`, `property-duplicate`, `generics-conflict`, `event-description-ambiguous`, `jsdoc-tag-dropped`, `types-inline-unresolved` — a type fell back to `any`). Plain `strict: true` / `--strict` fails on both, unchanged from before. Pass `strict: "errors"` (or `--strict=errors`) to fail CI only on `error`-severity diagnostics, letting `any`-fallback warnings through:
|
|
453
455
|
|
|
454
456
|
```sh
|
|
455
457
|
npx sveld --json --strict=errors
|
|
@@ -2667,6 +2669,16 @@ function render(value: unknown, props: ComponentProps) {
|
|
|
2667
2669
|
|
|
2668
2670
|
Both forms support the same modifiers as typedef properties elsewhere in this doc: optional properties (`[name]`), default values (`[name=value]`), and nested/discriminated-union shapes. See the linked sections above for full signatures and worked examples with generated output.
|
|
2669
2671
|
|
|
2672
|
+
A description can wrap onto continuation lines, which run until the next tag. Indent them past the `*` gutter to keep them attached to the tag unambiguously; an unindented line right above an `@event`/`@typedef`/`@slot` with no description of its own is read as that tag's description instead, and an unindented line after an event's last `@property` describes the event.
|
|
2673
|
+
|
|
2674
|
+
```js
|
|
2675
|
+
/**
|
|
2676
|
+
* @typedef {object} Config
|
|
2677
|
+
* @property {number} itemHeight Height of each item in pixels, used for
|
|
2678
|
+
* virtualization math.
|
|
2679
|
+
*/
|
|
2680
|
+
```
|
|
2681
|
+
|
|
2670
2682
|
### `@callback`
|
|
2671
2683
|
|
|
2672
2684
|
The `@callback` tag defines a function type with `@param` and `@returns`, following the [TypeScript JSDoc `@callback` spec](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#callback). Like `@typedef`, callbacks are exported from the generated `.d.ts`.
|
package/lib/browser.d.ts
CHANGED
|
@@ -110,11 +110,22 @@ interface ComponentPropParam {
|
|
|
110
110
|
optional?: boolean;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
interface ComponentPropReExport {
|
|
114
|
+
/** Module specifier as written in the source (e.g. `"./utils.js"`). */
|
|
115
|
+
from: string;
|
|
116
|
+
/** Name `from` exports: `"default"` for a default import, `"*"` for `export *` or a namespace import. */
|
|
117
|
+
imported: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
113
120
|
interface ComponentProp {
|
|
114
|
-
/** Public prop name
|
|
121
|
+
/** Public prop name; `"*"` for a bare `export * from "..."`. */
|
|
115
122
|
name: string;
|
|
116
|
-
/**
|
|
117
|
-
|
|
123
|
+
/**
|
|
124
|
+
* `"let"` (required), `"const"` (default), or `"function"`. `"re-export"`
|
|
125
|
+
* is module-export only: `export { x } from "..."`, `export * from "..."`,
|
|
126
|
+
* or `export { x }` of an imported binding, written to the `.d.ts` as-is.
|
|
127
|
+
*/
|
|
128
|
+
kind: "let" | "const" | "function" | "re-export";
|
|
118
129
|
/** True when declared with `const`. */
|
|
119
130
|
constant: boolean;
|
|
120
131
|
/** TypeScript type text. */
|
|
@@ -133,6 +144,12 @@ interface ComponentProp {
|
|
|
133
144
|
params?: ComponentPropParam[];
|
|
134
145
|
/** From JSDoc `@returns` on function props. */
|
|
135
146
|
returnType?: string;
|
|
147
|
+
/**
|
|
148
|
+
* A function's own type parameter list from its `@template` tags (e.g.
|
|
149
|
+
* `T extends { id: string }`), without the angle brackets. Also prefixed
|
|
150
|
+
* onto `type` when that signature is built from `@param`/`@returns`.
|
|
151
|
+
*/
|
|
152
|
+
typeParameters?: string;
|
|
136
153
|
/**
|
|
137
154
|
* True for arrow/function-expression initializers and bare `function`
|
|
138
155
|
* declarations in every mode; additionally true for a function-shaped
|
|
@@ -158,6 +175,8 @@ interface ComponentProp {
|
|
|
158
175
|
tags?: JsDocPassthroughTag[];
|
|
159
176
|
/** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */
|
|
160
177
|
internal?: boolean;
|
|
178
|
+
/** Set when `kind` is `"re-export"`. */
|
|
179
|
+
reExport?: ComponentPropReExport;
|
|
161
180
|
/** Source range when available. */
|
|
162
181
|
source?: SourceRange;
|
|
163
182
|
}
|
|
@@ -420,8 +439,17 @@ export class ComponentParser {
|
|
|
420
439
|
tags?: JsDocPassthroughTag[];
|
|
421
440
|
sveldIgnore?: string[];
|
|
422
441
|
internal: boolean;
|
|
442
|
+
typeParameters?: string;
|
|
423
443
|
} | undefined;
|
|
424
444
|
private addModuleExport;
|
|
445
|
+
/**
|
|
446
|
+
* Resolves one `export { local as exported }` specifier to the variable
|
|
447
|
+
* declarator it names. Each specifier resolves on its own, so
|
|
448
|
+
* `export { a, b }` exports both, and `const a = 1, b = ""; export { b }`
|
|
449
|
+
* exports `b`'s declarator rather than the first one in the declaration.
|
|
450
|
+
*/
|
|
451
|
+
private resolveExportSpecifier;
|
|
452
|
+
private recordUnresolvedExportSpecifier;
|
|
425
453
|
/**
|
|
426
454
|
* @example
|
|
427
455
|
* ```ts
|
|
@@ -478,7 +506,7 @@ export class ComponentParser {
|
|
|
478
506
|
parseSvelteComponent(source: string, diagnostics: ComponentParserDiagnostics): ParsedComponent;
|
|
479
507
|
}
|
|
480
508
|
|
|
481
|
-
export type SveldDiagnosticKind = "prop-unknown-type" | "context-any-type" | "slot-missing-type" | "event-no-source" | "example-compile-error" | "example-syntax-error" | "syntax-skipped" | "rest-props-unresolved" | "context-duplicate-key" | "spread-unresolved" | "export-unresolved" | "extend-props-target-missing" | "extend-props-duplicate" | "extend-props-override" | "jsdoc-unknown-tag" | "typedef-duplicate" | "property-duplicate" | "generics-conflict" | "jsdoc-tag-dropped" | "internal-typedef-referenced" | "types-inline-unresolved";
|
|
509
|
+
export type SveldDiagnosticKind = "prop-unknown-type" | "context-any-type" | "slot-missing-type" | "event-no-source" | "example-compile-error" | "example-syntax-error" | "syntax-skipped" | "rest-props-unresolved" | "context-duplicate-key" | "spread-unresolved" | "export-unresolved" | "module-export-conflict" | "extend-props-target-missing" | "extend-props-duplicate" | "extend-props-override" | "jsdoc-unknown-tag" | "typedef-duplicate" | "property-duplicate" | "generics-conflict" | "event-description-ambiguous" | "jsdoc-tag-dropped" | "internal-typedef-referenced" | "types-inline-unresolved";
|
|
482
510
|
|
|
483
511
|
type SveldDiagnosticSeverity = "error" | "warning";
|
|
484
512
|
|