diagnostics.ts

Diagnostic collection for source analysis.

Provides structured error/warning collection during TypeScript and Svelte analysis, replacing silent catch blocks with actionable diagnostics.

Error Handling Contract

The pipeline accumulates failures into the diagnostics array and keeps going — analysis continues, declarations/members reach the output with partial: true when extraction failed mid-flight, and the caller decides how to react. Producers include type resolution failures, individual member/prop extraction failures, svelte2tsx transform failures, source-map construction failures, import lex / resolver failures, and duplicate declarations.

A small set of conditions still throws from public entry points — these are setup-level, not per-file: missing tsconfig.json (loadTsconfig), Svelte <5 detected (transformSvelteSource), or strict discovery: 'exports' mode with no resolvable exports (discoverSourceFiles). Wrap the top-level analyze / analyzeFromFiles call if you want to handle these.

Usage Pattern

const {modules, diagnostics} = await analyze({sourceFiles, sourceOptions}); if (hasErrors(diagnostics)) { for (const err of errorsOf(diagnostics)) { console.error(formatDiagnostic(err)); } } for (const warning of warningsOf(diagnostics)) { console.warn(formatDiagnostic(warning)); }

Schema-Validated Plain Data

AnalyzeResultJson.diagnostics is Array<Diagnostic> — no wrapper object, no methods, no private fields. Round-trip-safe through JSON.stringify / z.array(Diagnostic).parse and symmetric with AnalyzeResultJson.modules (also Zod-validated). The full envelope is itself a Zod schema (AnalyzeResultJson in analyze-core.ts) with both fields defaulting to [], so the whole {modules, diagnostics} shape round-trips through JSON.stringify(result, compactReplacer) / AnalyzeResultJson.parse even when one or both arrays are empty (the wire form becomes {} and .parse() restores the defaults). Use the free helpers hasErrors, errorsOf, byKind for queries; mutate the array with native Array.push.

File Path Contract

Diagnostic.file is always project-root-relative — no leading slash, no ./ prefix. analyze / analyzeFromFiles and the session (setFile/setFiles at ingest, query at analysis) normalize paths from all sources (extraction, discovery, dependency resolution) before returning. Consumers that need an absolute path can rejoin with projectRoot.

It names a *file*, not a module: ModuleJson.path is relative to sourceRoot, so file is not a lookup key into modules.

view source

Declarations
#

25 declarations

AliasLostDiagnostic
#

diagnostics.ts view source

{ aliasName: string; file: string; message: string; severity: "error" | "warning"; kind: "alias_lost"; line?: number | undefined; column?: number | undefined; } import {AliasLostDiagnostic} from 'svelte-docinfo/diagnostics.js';

An exported type alias loses its name at use sites.

The alias's right-hand side (an indexed access or conditional — z.infer<typeof S>, valibot's InferOutput) resolves to a pre-existing interned type that TypeScript never retroactively stamps an alias symbol on, so unannotated positions document the expansion instead of the name. Fires only where nothing self-heals: a loss the alias registry recovers (typeInfo emits {kind: 'reference', name} at use sites) is suppressed, as are literal-only unions (z.enum outputs) and brand-like intersections (.brand()) — readable degradations with no author-side fix worth demanding. @nodocs on the declaration suppresses. The author-side escape for a flagged alias is a nominal symbol, e.g. interface Foo extends z.infer<typeof S> {} where applicable.

Always warning, query-time category (recomputed each query()).

aliasName

Name of the alias whose right-hand side resolves to a nameless type.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "alias_lost"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

byKind
#

diagnostics.ts view source

also exported from index.ts

<K extends DiagnosticKind>(diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | ... 14 more ... | { ...; })[], kind: K): (Extract<...> | ... 14 more ... | Extract<...>)[] import {byKind} from 'svelte-docinfo/diagnostics.js';

Get diagnostics of a specific kind, narrowed to the matching variant.

diagnostics

type ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

kind

type K

returns

(Extract<{ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; }, { kind: K; }> | ... 14 more ... | Extract<...>)[]

generics

byKind<K extends DiagnosticKind>
K
constraint DiagnosticKind

ClassMemberDiagnostic
#

diagnostics.ts view source

{ className: string; memberName: string; file: string; message: string; severity: "error" | "warning"; kind: "class_member_failed"; line?: number | undefined; column?: number | undefined; } import {ClassMemberDiagnostic} from 'svelte-docinfo/diagnostics.js';

Class member analysis failed.

className

Name of the class.

type string

memberName

Name of the member that failed.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "class_member_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

Diagnostic
#

diagnostics.ts view source

also exported from index.ts

{ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; } import {Diagnostic} from 'svelte-docinfo/diagnostics.js';

Discriminated union of all diagnostic variants.

DiagnosticKind
#

diagnostics.ts view source

also exported from index.ts

"type_extraction_failed" | "signature_analysis_failed" | "class_member_failed" | "svelte_prop_failed" | "legacy_props" | "module_skipped" | "module_unreadable" | "import_parse_failed" | ... 7 more ... | "alias_lost" import {DiagnosticKind} from 'svelte-docinfo/diagnostics.js';

Discriminant for Diagnostic variant types.

DiagnosticSeverity
#

diagnostics.ts view source

also exported from index.ts

"error" | "warning" import {DiagnosticSeverity} from 'svelte-docinfo/diagnostics.js';

Diagnostic severity levels.

  • 'error' — analysis failed, declaration may be incomplete or missing data
  • 'warning' — partial success, something seems off but analysis continued

DuplicateCommentDiagnostic
#

diagnostics.ts view source

{ commentType: "module_comment" | "doc_comment"; file: string; message: string; severity: "error" | "warning"; kind: "duplicate_comment"; line?: number | undefined; column?: number | undefined; } import {DuplicateCommentDiagnostic} from 'svelte-docinfo/diagnostics.js';

Duplicate comment sources detected (e.g., both HTML and JSDoc @module, or both HTML @component and JSDoc for component docComment).

commentType

Which comment type is duplicated.

type "module_comment" | "doc_comment"

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "duplicate_comment"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

DuplicateDeclarationDiagnostic
#

diagnostics.ts view source

{ declarationName: string; modules: string[]; file: string; message: string; severity: "error" | "warning"; kind: "duplicate_declaration"; line?: number | undefined; column?: number | undefined; } import {DuplicateDeclarationDiagnostic} from 'svelte-docinfo/diagnostics.js';

A declaration name appears in more than one module.

Library docs assume a flat namespace — two modules exporting the same name collide when consumers import {name}. Emitted at warning severity so the analysis result remains usable; consumers who want it fatal can promote via onDuplicates: 'throw' or by inspecting the diagnostic. The default slot (name === 'default') is excluded — every module owns its own.

declarationName

The duplicated declaration name.

type string

modules

Module paths where the name was defined (>= 2).

ModuleJson.path values — relative to sourceRoot, so a different base than the record's file (project-root-relative, like every diagnostic). The two disagree textually whenever sourceRoot is non-empty; each names what it says it names, a module vs. a file.

type string[]

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "duplicate_declaration"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

errorsOf
#

diagnostics.ts view source

also exported from index.ts

(diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]): ({ ...; } | ... 14 more ... | { ...; })[] import {errorsOf} from 'svelte-docinfo/diagnostics.js';

Get all error-severity diagnostics.

diagnostics

type ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

returns

({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

formatDiagnostic
#

diagnostics.ts view source

also exported from index.ts

(diagnostic: { symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; }): string import {formatDiagnostic} from 'svelte-docinfo/diagnostics.js';

Format a diagnostic for display.

Assumes diagnostic.file is project-root-relative (the contract enforced by analyze / analyzeFromFiles). The displayed path is prefixed with ./.

diagnostic

the diagnostic to format

type { symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; }

returns

string

formatted string like './file.ts:10:5: error: message'

examples

for (const d of errorsOf(diagnostics)) { console.error(formatDiagnostic(d)); }

hasErrors
#

diagnostics.ts view source

also exported from index.ts

(diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]): boolean import {hasErrors} from 'svelte-docinfo/diagnostics.js';

Check if any error-severity diagnostics were collected.

diagnostics

type ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

returns

boolean

hasWarnings
#

diagnostics.ts view source

also exported from index.ts

(diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]): boolean import {hasWarnings} from 'svelte-docinfo/diagnostics.js';

Check if any warning-severity diagnostics were collected.

diagnostics

type ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

returns

boolean

ImportParseDiagnostic
#

diagnostics.ts view source

{ file: string; message: string; severity: "error" | "warning"; kind: "import_parse_failed"; line?: number | undefined; column?: number | undefined; } import {ImportParseDiagnostic} from 'svelte-docinfo/diagnostics.js';

Import parsing failed during dependency resolution.

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "import_parse_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

LegacyPropsDiagnostic
#

diagnostics.ts view source

{ componentName: string; propNames: string[]; file: string; message: string; severity: "error" | "warning"; kind: "legacy_props"; line?: number | undefined; column?: number | undefined; } import {LegacyPropsDiagnostic} from 'svelte-docinfo/diagnostics.js';

Legacy (runes-less) component props detected — not extracted.

export let components are still-legal Svelte 5 syntax, but prop extraction anchors on the $props() declaration, so their props yield no ComponentPropJson entries. Emitted once per component, listing the detected prop names — exported let/var statements plus export-clause renames of mutable bindings (export {a as b}) — with line pointing at the first legacy prop export in the original .svelte source.

componentName

Name of the component.

type string

propNames

Exported prop names, in source order.

type string[]

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "legacy_props"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

MisplacedTagDiagnostic
#

diagnostics.ts view source

{ tagName: "default" | "mutates" | "throws" | "since" | "example" | "deprecated" | "internal" | "see" | "nodocs"; file: string; message: string; severity: "error" | "warning"; kind: "misplaced_tag"; functionName?: string | undefined; line?: number | undefined; column?: number | undefined; } import {MisplacedTagDiagnostic} from 'svelte-docinfo/diagnostics.js';

A JSDoc tag found somewhere it has no effect.

Two contexts emit this:

  • Non-primary overload signature — symbol-scope tags (@example, @deprecated, @internal, @since, @see, @throws, @mutates, @default, @nodocs) describe the function as a whole, not individual signatures. The primary signature's JSDoc feeds the parent declaration's symbol-level extraction; tags on non-primary overload signatures are silently dropped from output. This diagnostic surfaces them so authors can move them to the primary signature. @default and @nodocs are included even though overloads never carry a defaultValue or per-overload exclusion: their presence on a non-primary signature is always a misplacement.
  • Module comment@nodocs has no module-level meaning (it applies to declarations and export statements); in a @module comment the tag does nothing except remain verbatim in moduleComment text. To omit a module from analysis, use exclude patterns instead.

tagName

The tag name without the @ prefix (e.g., 'example', 'deprecated').

type "default" | "mutates" | "throws" | "since" | "example" | "deprecated" | "internal" | "see" | "nodocs"

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "misplaced_tag"

functionName?

Name of the enclosing symbol: the function or method whose overload carries the misplaced tag. Absent for module-comment misplacements (no enclosing symbol).

type string

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

ModuleSkippedDiagnostic
#

diagnostics.ts view source

{ reason: "not_in_program" | "no_analyzer" | "requires_program"; file: string; message: string; severity: "error" | "warning"; kind: "module_skipped"; line?: number | undefined; column?: number | undefined; } import {ModuleSkippedDiagnostic} from 'svelte-docinfo/diagnostics.js';

Module was skipped during the analysis pass.

Always warning severity — the rest of the analysis still runs and the module's absence in modules reflects the skip. Reasons:

  • not_in_program — the file wasn't in the ts.Program (race between session ingest and query, or virtual file missing for a .svelte)
  • no_analyzer — file extension didn't match any analyzer
  • requires_program — Svelte file reached the non-Svelte dispatcher (caller should use the session API instead of analyzeModule directly)

Discovery-time file-read failures are a separate kind: module_unreadable.

reason

Reason the module was skipped.

type "not_in_program" | "no_analyzer" | "requires_program"

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "module_skipped"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

ModuleUnreadableDiagnostic
#

diagnostics.ts view source

{ file: string; message: string; severity: "error" | "warning"; kind: "module_unreadable"; line?: number | undefined; column?: number | undefined; } import {ModuleUnreadableDiagnostic} from 'svelte-docinfo/diagnostics.js';

File discovered via package.json exports exists but couldn't be read.

Always error severity — discovery-time, emitted by discoverFromExports when readFile fails (permission denied, FS error). Distinct from module_skipped so severity is a stable per-kind property and downstream consumers can route discovery failures separately from analysis-pass skips.

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "module_unreadable"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

ResolverFailedDiagnostic
#

diagnostics.ts view source

{ specifier: string; file: string; message: string; severity: "error" | "warning"; kind: "resolver_failed"; line?: number | undefined; column?: number | undefined; } import {ResolverFailedDiagnostic} from 'svelte-docinfo/diagnostics.js';

Import resolver threw while resolving a specifier.

Distinguishes a buggy resolver from a legitimately unresolvable specifier: resolvers that return null for unknown specifiers stay silent (the normal "external package" case); resolvers that *throw* surface here so consumers can fix the resolver. Recoverable — the session treats the throw as null and continues, so analysis still runs but with a missing dependency edge.

Emitted at ingest time by the session's resolve phase.

specifier

The import specifier the resolver failed on.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "resolver_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

SignatureAnalysisDiagnostic
#

diagnostics.ts view source

{ functionName: string; file: string; message: string; severity: "error" | "warning"; kind: "signature_analysis_failed"; line?: number | undefined; column?: number | undefined; } import {SignatureAnalysisDiagnostic} from 'svelte-docinfo/diagnostics.js';

Function/method signature analysis failed.

functionName

Name of the function or method.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "signature_analysis_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

SourceMapFailedDiagnostic
#

diagnostics.ts view source

{ file: string; message: string; severity: "error" | "warning"; kind: "source_map_failed"; line?: number | undefined; column?: number | undefined; } import {SourceMapFailedDiagnostic} from 'svelte-docinfo/diagnostics.js';

Source map parsing failed for a Svelte virtual file.

Analysis continues without position mapping: query-time diagnostics drop line/column rather than point into svelte2tsx-generated TS — those emitted against the virtual via remapVirtualDiagnosticPositions, svelte_prop_failed at its own emission site — while declaration sourceLines fall back to virtual positions. Rare; usually signals a malformed or incompatible svelte2tsx output.

Emitted at ingest time by transformSvelteSource (in svelte.ts); flows through setFile/setFiles ingest diagnostics rather than the analysis pass.

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "source_map_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

SveltePropDiagnostic
#

diagnostics.ts view source

{ componentName: string; propName: string; file: string; message: string; severity: "error" | "warning"; kind: "svelte_prop_failed"; line?: number | undefined; column?: number | undefined; } import {SveltePropDiagnostic} from 'svelte-docinfo/diagnostics.js';

Svelte prop type resolution failed.

file is the original .svelte path, so line/column are present only when the prop's declaration lives in the component's own virtual *and* maps back to the original source — an imported props type or a node svelte2tsx synthesized leaves the position absent rather than publishing a virtual line, the rule remapVirtualDiagnosticPositions applies to extractor diagnostics.

componentName

Name of the component.

type string

propName

Name of the prop.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "svelte_prop_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

TransformFailedDiagnostic
#

diagnostics.ts view source

{ file: string; message: string; severity: "error" | "warning"; kind: "transform_failed"; line?: number | undefined; column?: number | undefined; } import {TransformFailedDiagnostic} from 'svelte-docinfo/diagnostics.js';

svelte2tsx transform threw for a .svelte file.

Unrecoverable at ingest — the file's owned-entry stays in the session (virtual: undefined, unfilteredDeps: [], transformFailed: true) so query() can synthesize a placeholder ModuleJson (partial: true, empty declarations). The originating error message lives in message; this diagnostic is the authoritative cause-of-failure signal.

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "transform_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

TypeExtractionDiagnostic
#

diagnostics.ts view source

{ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } import {TypeExtractionDiagnostic} from 'svelte-docinfo/diagnostics.js';

Type extraction failed (e.g., complex or recursive types).

symbolName

Name of the symbol whose type couldn't be extracted.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "type_extraction_failed"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

UnknownParamDiagnostic
#

diagnostics.ts view source

{ paramName: string; functionName: string; file: string; message: string; severity: "error" | "warning"; kind: "unknown_param"; line?: number | undefined; column?: number | undefined; } import {UnknownParamDiagnostic} from 'svelte-docinfo/diagnostics.js';

@param tag references a name that doesn't match any actual parameter.

Usually a typo (@param argz for parameter args) or stale doc after a rename. The description is dropped; analysis continues.

paramName

The @param key that didn't match a real parameter.

type string

functionName

Name of the function or method.

type string

file

File path relative to project root (no leading slash, no ./ prefix).

Normalized at every public API boundary — session.setFile/setFiles (ingest-time), session.query (query-time, via analyzeCore), and the one-shot wrappers analyze / analyzeFromFiles. Producers inside the pipeline may write absolute or virtual paths (e.g., Foo.svelte.__svelte2tsx__.ts); normalization rewrites them to project-relative form before they reach consumers.

The exception is discoverydiscoverSourceFiles / discoverFromExports return their diagnostics unnormalized, since they run before any session exists. Their file is already project-root-relative, but message can embed an absolute path (an fs error names the file it failed on), so a consumer wiring discovery up itself owns the normalizeDiagnosticPaths call — analyzeFromFiles and the Vite plugin both make it before merging.

The absolute form is the one to write. Normalization deliberately leaves an already-relative path alone (relativizing it would resolve against cwd), so a producer writing a ModuleJson.path — relative to sourceRoot, a different base — passes through untouched and publishes the same file under a second name. Absolute is what the pass can actually correct.

type string

message

Human-readable description of the issue.

type string

severity

type "error" | "warning"

kind

type "unknown_param"

line?

Line number (1-based), absent if location unavailable.

type number

column?

Column number (1-based), absent if location unavailable.

type number

warningsOf
#

diagnostics.ts view source

also exported from index.ts

(diagnostics: ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]): ({ ...; } | ... 14 more ... | { ...; })[] import {warningsOf} from 'svelte-docinfo/diagnostics.js';

Get all warning-severity diagnostics.

diagnostics

type ({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

returns

({ symbolName: string; file: string; message: string; severity: "error" | "warning"; kind: "type_extraction_failed"; line?: number | undefined; column?: number | undefined; } | { functionName: string; ... 5 more ...; column?: number | undefined; } | ... 13 more ... | { ...; })[]

Imported by
#