svelte-docinfo 0.11.0 → 0.13.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.
- package/README.md +22 -5
- package/dist/analyze-core.d.ts +67 -1351
- package/dist/analyze-core.d.ts.map +1 -1
- package/dist/analyze-core.js +69 -25
- package/dist/analyze.d.ts +30 -2
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +13 -7
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +9 -2
- package/dist/declaration-build.d.ts +10 -11
- package/dist/declaration-build.d.ts.map +1 -1
- package/dist/declaration-build.js +3 -3
- package/dist/declaration-helpers.d.ts +17 -13
- package/dist/declaration-helpers.d.ts.map +1 -1
- package/dist/declaration-helpers.js +17 -13
- package/dist/diagnostics.d.ts +267 -742
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +142 -123
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/postprocess.d.ts +5 -2
- package/dist/postprocess.d.ts.map +1 -1
- package/dist/schema.d.ts +50 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +49 -0
- package/dist/session.d.ts +64 -22
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +36 -18
- package/dist/svelte-legacy.d.ts +145 -0
- package/dist/svelte-legacy.d.ts.map +1 -0
- package/dist/svelte-legacy.js +210 -0
- package/dist/svelte-scripts.d.ts +144 -0
- package/dist/svelte-scripts.d.ts.map +1 -0
- package/dist/svelte-scripts.js +242 -0
- package/dist/svelte.d.ts +50 -13
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +369 -236
- package/dist/tsdoc.js +1 -1
- package/dist/types.d.ts +1657 -4881
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +442 -285
- package/dist/typescript-alias-registry.d.ts.map +1 -1
- package/dist/typescript-alias-registry.js +10 -5
- package/dist/typescript-exports.d.ts.map +1 -1
- package/dist/typescript-exports.js +245 -47
- package/dist/typescript-extract-shared.d.ts +38 -3
- package/dist/typescript-extract-shared.d.ts.map +1 -1
- package/dist/typescript-extract-shared.js +5 -3
- package/dist/typescript-extract-type-json.d.ts +2 -1
- package/dist/typescript-extract-type-json.d.ts.map +1 -1
- package/dist/typescript-extract-type-json.js +17 -5
- package/dist/typescript-program.d.ts +74 -5
- package/dist/typescript-program.d.ts.map +1 -1
- package/dist/typescript-program.js +65 -5
- package/dist/vite.d.ts +21 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +115 -11
- package/package.json +5 -6
- package/virtual-svelte-docinfo.d.ts +7 -7
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ in the [npm package](https://www.npmjs.com/package/svelte-docinfo).
|
|
|
18
18
|
npm i -D svelte-docinfo
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Peer dependencies: `svelte` 5+, `svelte2tsx`, `typescript` 5.9+ or 6
|
|
22
|
-
|
|
21
|
+
Peer dependencies: `svelte` 5+, `svelte2tsx`, and `typescript` 5.9+ or 6 (npm 7+
|
|
22
|
+
installs them automatically), plus an optional `vite` 6+ for the Vite plugin.
|
|
23
23
|
|
|
24
24
|
- [Quick start](#quick-start)
|
|
25
25
|
- [Vite plugin](#vite-plugin)
|
|
@@ -186,6 +186,19 @@ All three produce the same JSON shape:
|
|
|
186
186
|
}
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
Defaulted fields are left out of the JSON: empty arrays and `false` flags. To restore them
|
|
190
|
+
and validate the shape, parse it with `parseAnalyzeResult` (`parseModuleJson` for one module,
|
|
191
|
+
`parseDiagnostics` for diagnostics alone):
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
import { parseAnalyzeResult } from 'svelte-docinfo';
|
|
195
|
+
|
|
196
|
+
const { modules, diagnostics } = parseAnalyzeResult(JSON.parse(json));
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The parse helpers are the stable entry point. The schemas behind them (`AnalyzeResultJson`,
|
|
200
|
+
`ModuleJson`, `DeclarationJson`, …) are exported too, as [valibot](https://valibot.dev/) schemas.
|
|
201
|
+
|
|
189
202
|
The [extraction demo](https://svelte-docinfo.fuz.dev/demo/extraction) has more examples,
|
|
190
203
|
and see the docs for the complete [output format](https://svelte-docinfo.fuz.dev/docs/output-format).
|
|
191
204
|
You may also want to browse the [test fixtures](https://github.com/fuzdev/svelte-docinfo/tree/main/src/test/fixtures).
|
|
@@ -232,6 +245,9 @@ Plugin options:
|
|
|
232
245
|
| `resolveDependencies` | `true` | Resolve import dependencies. When `false`, `dependencies`/`dependents` stay empty. |
|
|
233
246
|
| `hmrDebounceMs` | `100` | Dev re-analysis debounce delay in milliseconds. |
|
|
234
247
|
| `onDuplicates` | — | Opt-in check that names are unique across modules, for packages with a flat export namespace: `'diagnostic'` \| `'warn'` \| `'throw'`. Off by default. |
|
|
248
|
+
| `tsconfig` | `'tsconfig.json'` | Path to the tsconfig, relative to `projectRoot`, or `false` to analyze without one (built-in strict options, with `compilerOptions` merged on top). |
|
|
249
|
+
| `compilerOptions` | — | Compiler options merged over the tsconfig's, per key. |
|
|
250
|
+
| `rootFileNames` | the tsconfig's roots | The program's root files in place of the tsconfig's: a list, or a function over the tsconfig's roots (`declarationFileRoots`, from `svelte-docinfo/typescript-program.js`, keeps the declaration files). Narrowing speeds up cold analysis; an ambient type declared in a dropped root resolves to `any`. |
|
|
235
251
|
|
|
236
252
|
Source-scope notes (shared with the [CLI](#cli) and `analyzeFromFiles`):
|
|
237
253
|
|
|
@@ -281,6 +297,8 @@ All CLI options:
|
|
|
281
297
|
| `--only <pattern>` | Glob filter applied to module paths in output (repeatable). Full project is still analyzed (re-exports/dependents stay correct); diagnostics aren't filtered |
|
|
282
298
|
| `--no-resolve-dependencies` | Disable dependency resolution |
|
|
283
299
|
| `--pretty` | Pretty-print JSON output (default: compact) |
|
|
300
|
+
| `--tsconfig <path>` | Path to the tsconfig, relative to project root (default: `tsconfig.json`, searched upward from project root) |
|
|
301
|
+
| `--no-tsconfig` | Analyze without a tsconfig, using built-in strict compiler options |
|
|
284
302
|
| `-q, --quiet` | Suppress info messages on stderr (warnings and errors still print) |
|
|
285
303
|
| `--on-duplicates <mode>` | Opt-in check that names are unique across modules, for packages with a flat export namespace: `diagnostic` \| `warn` \| `throw` (default: off) |
|
|
286
304
|
| `-V, --version` | Show version number |
|
|
@@ -334,7 +352,7 @@ See the [API docs](https://svelte-docinfo.fuz.dev/docs/api) for the full referen
|
|
|
334
352
|
- **Full type resolution**: infers complex types without manual annotations, including generics, imported types, and inferred return types
|
|
335
353
|
- **Structured types**: an optional `typeInfo` tree (`TypeJson`) beside the flat type strings on props, parameters, return types (`returnTypeInfo`, overloads included), members, and variable/type declarations — union and intersection members (alias names kept), reference type arguments, and array/tuple elements, so a union alias documents more than its own name. Absent wherever the flat string already says everything; `typeJsonToTokens`/`typeJsonToText` render it
|
|
336
354
|
- **TSDoc/JSDoc parsing**: the common doc tags (`@param`, `@returns`, `@throws`, `@example`, `@deprecated`, `@internal`, `@see`, `@since`, `@default`) plus `@nodocs`, `@mutates`, and `@module` for file-level comments; divergent spellings parse as synonyms (`@return`, `@defaultValue`). `@internal` marks unstable API (`internalMessage`) but stays documented — `@nodocs` is the exclusion. Dotted `@param obj.prop` tags fill `propertyDescriptions`, and inline `{@link}` survives in extracted text
|
|
337
|
-
- **Alias-lost name recovery**: TypeScript drops the name of an alias over an indexed access or conditional (`type Foo = z.infer<typeof S>`) and expands its structure at every use. `typeInfo` recovers it as `{kind: 'reference', name}`, from the written annotation where there is one and otherwise from a registry of the project's exported aliases (those references also carry `module` for exact linking). Losses nothing recovers surface as `alias_lost` warnings
|
|
355
|
+
- **Alias-lost name recovery**: TypeScript drops the name of an alias over an indexed access or conditional (`type Foo = z.infer<typeof S>`, or valibot's `v.InferOutput<typeof S>`) and expands its structure at every use. `typeInfo` recovers it as `{kind: 'reference', name}`, from the written annotation where there is one and otherwise from a registry of the project's exported aliases (those references also carry `module` for exact linking). Losses nothing recovers surface as `alias_lost` warnings
|
|
338
356
|
- **Merged value+type symbols**: `export const Foo = z.strictObject({...})` + `export type Foo = z.infer<typeof Foo>` documents the type meaning (structure and members), with `mergedValue: true` marking the name as also a runtime value; JSDoc falls back to the const's docs, and `generateImport` emits a value import
|
|
339
357
|
- **Svelte 5 component props**: extracts prop types, descriptions, defaults, and bindability via svelte2tsx, in source order (destructured external props follow, in destructuring order); generic components carry `genericParams`, and JS components (no `lang="ts"`) are supported — props come from the JSDoc `@type` on `$props()` or are inferred from untyped destructuring
|
|
340
358
|
- **External types**: props and members contributed by external packages (e.g. `HTMLButtonAttributes`) are filtered out and named in `externalTypes` — on components, type aliases, interfaces, and classes, including bags reached through local base types. A component prop named in the `$props()` destructuring (`let {type = 'button', ...rest} = $props()`) is documented anyway, since the component handles it
|
|
@@ -354,8 +372,7 @@ Known gaps:
|
|
|
354
372
|
|
|
355
373
|
- context tracking (transitive detection of common patterns seems tractable)
|
|
356
374
|
- standalone `namespace Foo {}` declarations and decorators are not yet supported
|
|
357
|
-
-
|
|
358
|
-
- legacy `export let` props aren't extracted (the component gets zero props), but a `legacy_props` warning names them
|
|
375
|
+
- legacy `export let` components document their props (all `bindable`), and a legacy component's default `<slot />` sets `acceptsChildren`, but named slots, slot props, events, and `$$restProps` aren't modeled — Svelte 5 snippets and callback props replace most of them
|
|
359
376
|
- `@nodocs` applies to declarations and export statements only; on a member or component prop it's ignored without a warning
|
|
360
377
|
|
|
361
378
|
[Issues](https://github.com/fuzdev/svelte-docinfo/issues) for bugs and
|