svelte-docinfo 0.7.0 → 0.8.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 +16 -9
- package/dist/analyze-core.d.ts +55 -27
- package/dist/analyze-core.d.ts.map +1 -1
- package/dist/analyze-core.js +51 -45
- package/dist/analyze.d.ts +12 -31
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +5 -3
- package/dist/cli.d.ts +4 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -3
- package/dist/concurrency.d.ts +6 -3
- package/dist/concurrency.d.ts.map +1 -1
- package/dist/concurrency.js +6 -3
- package/dist/dep-resolver.d.ts +6 -3
- package/dist/dep-resolver.d.ts.map +1 -1
- package/dist/dep-resolver.js +6 -3
- package/dist/diagnostics.d.ts +18 -9
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +20 -9
- package/dist/discovery.d.ts +16 -21
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +9 -17
- package/dist/error.d.ts +3 -4
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +3 -4
- package/dist/exports.d.ts +7 -7
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +8 -8
- package/dist/files.d.ts +0 -3
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +5 -5
- package/dist/index.js +1 -1
- package/dist/postprocess.d.ts +13 -6
- package/dist/postprocess.d.ts.map +1 -1
- package/dist/postprocess.js +13 -6
- package/dist/session.d.ts +36 -12
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +39 -24
- package/dist/source-config.d.ts +22 -19
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +14 -12
- package/dist/source.d.ts +17 -13
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +4 -7
- package/dist/svelte.d.ts +21 -4
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +48 -15
- package/dist/tsdoc.d.ts +4 -8
- package/dist/tsdoc.d.ts.map +1 -1
- package/dist/tsdoc.js +4 -8
- package/dist/types.d.ts +607 -171
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +71 -28
- package/dist/typescript-exports.d.ts +7 -7
- package/dist/typescript-exports.d.ts.map +1 -1
- package/dist/typescript-exports.js +15 -13
- package/dist/typescript-extract-class.d.ts +2 -1
- package/dist/typescript-extract-class.d.ts.map +1 -1
- package/dist/typescript-extract-class.js +7 -7
- package/dist/typescript-extract-function.js +3 -3
- package/dist/typescript-extract-shared.d.ts +32 -12
- package/dist/typescript-extract-shared.d.ts.map +1 -1
- package/dist/typescript-extract-shared.js +55 -34
- package/dist/typescript-extract-type-json.d.ts +11 -3
- package/dist/typescript-extract-type-json.d.ts.map +1 -1
- package/dist/typescript-extract-type-json.js +12 -9
- package/dist/typescript-extract-type-properties.js +3 -3
- package/dist/typescript-extract-type.js +7 -7
- package/dist/typescript-program.d.ts +23 -8
- package/dist/typescript-program.d.ts.map +1 -1
- package/dist/typescript-program.js +23 -14
- package/dist/vite.d.ts +12 -35
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +7 -6
- package/package.json +9 -29
- package/virtual-svelte-docinfo.d.ts +9 -7
|
@@ -76,7 +76,7 @@ export declare const createExtractContext: (program: ts.Program, checker: ts.Typ
|
|
|
76
76
|
* at all, so every `undefined` in the type is author-written and stripping
|
|
77
77
|
* would corrupt it: `x?: T | undefined` trimmed to `T`, `x?: T | null |
|
|
78
78
|
* undefined` to `T | null`, and a null-free multi-member union rebuilt through
|
|
79
|
-
* `getNonNullableType` (`x?: E | F` printed as `
|
|
79
|
+
* `getNonNullableType` (`x?: E | F` printed as `NonNullable<E> | NonNullable<F>`).
|
|
80
80
|
*
|
|
81
81
|
* Property sites only — component props, type-alias and interface properties,
|
|
82
82
|
* class properties. Optional *parameters* and optional *tuple elements* widen
|
|
@@ -135,6 +135,10 @@ export declare const getLocalExportStatement: (exportSymbol: ts.Symbol, sourceFi
|
|
|
135
135
|
* call here on a `ValueModule` symbol would fall through to `'variable'` and
|
|
136
136
|
* leak `typeof import("/abs/path")` into the output — keep the namespace
|
|
137
137
|
* dispatch in `analyzeExports`.
|
|
138
|
+
*
|
|
139
|
+
* Standalone `namespace Foo {}` declarations aren't modeled: they fall through
|
|
140
|
+
* to `'variable'` and document as `typeof Foo` (or `any` for a type-only
|
|
141
|
+
* namespace) with no members.
|
|
138
142
|
*/
|
|
139
143
|
export declare const inferDeclarationKind: (symbol: ts.Symbol, node: ts.Node) => DeclarationKind;
|
|
140
144
|
/**
|
|
@@ -150,7 +154,9 @@ export declare const inferDeclarationKind: (symbol: ts.Symbol, node: ts.Node) =>
|
|
|
150
154
|
* selected instead; value-space kinds (and unmerged symbols) keep the
|
|
151
155
|
* `valueDeclaration`-first selection. The merged value meaning goes
|
|
152
156
|
* undocumented under the one-declaration-per-export-name model — the type is
|
|
153
|
-
* what consumers look up.
|
|
157
|
+
* what consumers look up. A class+interface merge resolves value-space
|
|
158
|
+
* (`class`), so it documents the class with no doc fallback and no
|
|
159
|
+
* `mergedValue` marker — a class already implies value+type.
|
|
154
160
|
*/
|
|
155
161
|
export declare const selectDeclarationNode: (symbol: ts.Symbol) => ts.Declaration | undefined;
|
|
156
162
|
/**
|
|
@@ -175,7 +181,14 @@ export declare const selectDeclarationNode: (symbol: ts.Symbol) => ts.Declaratio
|
|
|
175
181
|
*
|
|
176
182
|
* Applies to the structured fields only. A callable's `typeSignature` comes from
|
|
177
183
|
* `checker.signatureToString`, which has no flag to omit the widening, so it renders
|
|
178
|
-
* optional parameters as the checker does — `(a?: number | undefined): void`.
|
|
184
|
+
* optional parameters as the checker does — `(a?: number | undefined): void`. The strip
|
|
185
|
+
* is top-level only, so an optional property nested in a printed object type keeps its
|
|
186
|
+
* widening too (`b: {c?: boolean}` → `"{ c?: boolean | undefined; }"`).
|
|
187
|
+
*
|
|
188
|
+
* The result is the checker's canonical rendering, not what an editor shows on hover:
|
|
189
|
+
* the language service prints from the declaration node, so for an alias-lost
|
|
190
|
+
* `type Foo = z.infer<typeof S>` (any alias over an indexed access or conditional) hover
|
|
191
|
+
* reads `Foo` while this carries the expanded, possibly truncated, structure.
|
|
179
192
|
*
|
|
180
193
|
* A non-union optional is printed as written, since there's no widening member to
|
|
181
194
|
* remove: `x?: undefined` stays `"undefined"` (stripping would leave `never`, the same
|
|
@@ -222,11 +235,12 @@ export declare const getTypeSignature: (type: ts.Type, checker: ts.TypeChecker,
|
|
|
222
235
|
* under `exactOptionalPropertyTypes` a written `fn?: (() => void) | undefined`
|
|
223
236
|
* classifies callable like `fn?: () => void` (that spelling is often forced
|
|
224
237
|
* there — assigning a possibly-`undefined` handler to the property requires
|
|
225
|
-
* it).
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
238
|
+
* it). Two cases stay non-callable and land as `kind: 'variable'` with the
|
|
239
|
+
* union kept: `| null` (a real value, per the paragraph above) and a
|
|
240
|
+
* *required* property's written `undefined` (nothing else carries it; `false`
|
|
241
|
+
* here is identity). The printed and structured outputs still gate their
|
|
242
|
+
* strips on `optionalWidened`, where a written `undefined` is content; on
|
|
243
|
+
* method sites the gate is moot, since method syntax can't write `| undefined`.
|
|
230
244
|
*/
|
|
231
245
|
export declare const getNonOptionalType: (type: ts.Type, checker: ts.TypeChecker, optional: boolean) => ts.Type;
|
|
232
246
|
/**
|
|
@@ -305,10 +319,10 @@ export declare const populatePropertyMember: (member: MemberJsonBuild, propType:
|
|
|
305
319
|
* The one visibility rule, shared by the two ways a class's members reach
|
|
306
320
|
* output: `extractClassInfo` walking `node.members` at the class's own
|
|
307
321
|
* declaration, and `filterDocumentedProperties` projecting a class *type* at a
|
|
308
|
-
* structural container (`type X = LocalClass`,
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* through
|
|
322
|
+
* structural container (`type X = LocalClass`, `type X = LocalGen<string>`).
|
|
323
|
+
* Held in one place so an alias over a class hides exactly what the class
|
|
324
|
+
* hides — the two paths disagreeing would leak `#` fields into `members`
|
|
325
|
+
* through the alias.
|
|
312
326
|
*
|
|
313
327
|
* `protected` is deliberately not private: it is part of the extension API a
|
|
314
328
|
* subclass author documents against. Only classes can declare either form —
|
|
@@ -380,6 +394,12 @@ export declare const filterDocumentedProperties: (type: ts.Type, typeNode: ts.No
|
|
|
380
394
|
* Only `extends` entries are passed by either caller: an interface has no
|
|
381
395
|
* other clause kind, and a class's `implements` adds no members.
|
|
382
396
|
*
|
|
397
|
+
* Scoped to the processed declaration's own heritage clauses — the same node
|
|
398
|
+
* `extends` and `members` come from — so on a merged interface only the
|
|
399
|
+
* selected block contributes, while a reference to that interface elsewhere
|
|
400
|
+
* descends every block. The three fields stay consistent with each other rather
|
|
401
|
+
* than with the descent.
|
|
402
|
+
*
|
|
383
403
|
* @mutates declaration - sets `externalTypes` when the walk finds any, left absent when not
|
|
384
404
|
*/
|
|
385
405
|
export declare const applyHeritageExternalTypes: (declaration: DeclarationJsonBuild, heritageTypes: ReadonlyArray<ts.ExpressionWithTypeArguments>, ctx: ExtractContext) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-extract-shared.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/typescript-extract-shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EAEnB,aAAa,EAEb,UAAU,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,KAAK,UAAU,EAA+B,MAAM,kBAAkB,CAAC;AAGhF,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAIN,KAAK,aAAa,EAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxB,uFAAuF;IACvF,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,oFAAoF;IACpF,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IACzC;;;;;OAKG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,EAAE,CAAC,OAAO,EACnB,SAAS,EAAE,CAAC,WAAW,EACvB,SAAS,mBAAmB,EAC5B,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,eAAe,aAAa,GAAG,SAAS,KACtC,cAMD,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,cAAc,EAAE,UAAU,OAAO,KAAG,OAC7B,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,MAAM,KAAG,OAItE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GACnC,cAAc,EAAE,CAAC,MAAM,EACvB,YAAY,EAAE,CAAC,UAAU,KAEvB;IAAE,IAAI,EAAE,EAAE,CAAC,eAAe,GAAG,EAAE,CAAC,eAAe,CAAC;IAAC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAA;CAAE,GAClF,SAcF,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"typescript-extract-shared.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/typescript-extract-shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;A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
import {
|
|
17
|
+
import { toErrorMessage } from './error.js';
|
|
18
18
|
import { stripVirtualSuffix } from './source.js';
|
|
19
19
|
import { applyToDeclaration, parseComment } from './tsdoc.js';
|
|
20
20
|
import { specifierExportedName, optionalWideningTarget, resolveTypeInfo } from './typescript-extract-type-json.js';
|
|
@@ -48,7 +48,7 @@ export const createExtractContext = (program, checker, options, diagnostics, ali
|
|
|
48
48
|
* at all, so every `undefined` in the type is author-written and stripping
|
|
49
49
|
* would corrupt it: `x?: T | undefined` trimmed to `T`, `x?: T | null |
|
|
50
50
|
* undefined` to `T | null`, and a null-free multi-member union rebuilt through
|
|
51
|
-
* `getNonNullableType` (`x?: E | F` printed as `
|
|
51
|
+
* `getNonNullableType` (`x?: E | F` printed as `NonNullable<E> | NonNullable<F>`).
|
|
52
52
|
*
|
|
53
53
|
* Property sites only — component props, type-alias and interface properties,
|
|
54
54
|
* class properties. Optional *parameters* and optional *tuple elements* widen
|
|
@@ -126,6 +126,10 @@ export const getLocalExportStatement = (exportSymbol, sourceFile) => {
|
|
|
126
126
|
* call here on a `ValueModule` symbol would fall through to `'variable'` and
|
|
127
127
|
* leak `typeof import("/abs/path")` into the output — keep the namespace
|
|
128
128
|
* dispatch in `analyzeExports`.
|
|
129
|
+
*
|
|
130
|
+
* Standalone `namespace Foo {}` declarations aren't modeled: they fall through
|
|
131
|
+
* to `'variable'` and document as `typeof Foo` (or `any` for a type-only
|
|
132
|
+
* namespace) with no members.
|
|
129
133
|
*/
|
|
130
134
|
export const inferDeclarationKind = (symbol, node) => {
|
|
131
135
|
// Check symbol flags
|
|
@@ -175,7 +179,9 @@ export const inferDeclarationKind = (symbol, node) => {
|
|
|
175
179
|
* selected instead; value-space kinds (and unmerged symbols) keep the
|
|
176
180
|
* `valueDeclaration`-first selection. The merged value meaning goes
|
|
177
181
|
* undocumented under the one-declaration-per-export-name model — the type is
|
|
178
|
-
* what consumers look up.
|
|
182
|
+
* what consumers look up. A class+interface merge resolves value-space
|
|
183
|
+
* (`class`), so it documents the class with no doc fallback and no
|
|
184
|
+
* `mergedValue` marker — a class already implies value+type.
|
|
179
185
|
*/
|
|
180
186
|
export const selectDeclarationNode = (symbol) => {
|
|
181
187
|
// Class/Function flags win in inferDeclarationKind, so only a flag set
|
|
@@ -221,7 +227,14 @@ const UNDEFINED_UNION_SUFFIX = ' | undefined';
|
|
|
221
227
|
*
|
|
222
228
|
* Applies to the structured fields only. A callable's `typeSignature` comes from
|
|
223
229
|
* `checker.signatureToString`, which has no flag to omit the widening, so it renders
|
|
224
|
-
* optional parameters as the checker does — `(a?: number | undefined): void`.
|
|
230
|
+
* optional parameters as the checker does — `(a?: number | undefined): void`. The strip
|
|
231
|
+
* is top-level only, so an optional property nested in a printed object type keeps its
|
|
232
|
+
* widening too (`b: {c?: boolean}` → `"{ c?: boolean | undefined; }"`).
|
|
233
|
+
*
|
|
234
|
+
* The result is the checker's canonical rendering, not what an editor shows on hover:
|
|
235
|
+
* the language service prints from the declaration node, so for an alias-lost
|
|
236
|
+
* `type Foo = z.infer<typeof S>` (any alias over an indexed access or conditional) hover
|
|
237
|
+
* reads `Foo` while this carries the expanded, possibly truncated, structure.
|
|
225
238
|
*
|
|
226
239
|
* A non-union optional is printed as written, since there's no widening member to
|
|
227
240
|
* remove: `x?: undefined` stays `"undefined"` (stripping would leave `never`, the same
|
|
@@ -275,11 +288,12 @@ export const getTypeSignature = (type, checker, optional) => {
|
|
|
275
288
|
* under `exactOptionalPropertyTypes` a written `fn?: (() => void) | undefined`
|
|
276
289
|
* classifies callable like `fn?: () => void` (that spelling is often forced
|
|
277
290
|
* there — assigning a possibly-`undefined` handler to the property requires
|
|
278
|
-
* it).
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
291
|
+
* it). Two cases stay non-callable and land as `kind: 'variable'` with the
|
|
292
|
+
* union kept: `| null` (a real value, per the paragraph above) and a
|
|
293
|
+
* *required* property's written `undefined` (nothing else carries it; `false`
|
|
294
|
+
* here is identity). The printed and structured outputs still gate their
|
|
295
|
+
* strips on `optionalWidened`, where a written `undefined` is content; on
|
|
296
|
+
* method sites the gate is moot, since method syntax can't write `| undefined`.
|
|
283
297
|
*/
|
|
284
298
|
export const getNonOptionalType = (type, checker, optional) => optionalWideningTarget(type, checker, optional).target;
|
|
285
299
|
/**
|
|
@@ -450,14 +464,12 @@ const applyReturnType = (target, sig, ctx) => {
|
|
|
450
464
|
* `returnDescription`. These are signature-scope: each overload may
|
|
451
465
|
* describe its own parameters and return value distinctly.
|
|
452
466
|
*
|
|
453
|
-
* Symbol-scope tags
|
|
454
|
-
* `@throws`, `@mutates`) describe the function as a whole and belong on the parent
|
|
467
|
+
* Symbol-scope tags describe the function as a whole and belong on the parent
|
|
455
468
|
* declaration. The primary overload — the one whose JSDoc text matches the
|
|
456
|
-
* parent's `docComment` — already feeds the parent's symbol-level extraction
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* author at the primary signature.
|
|
469
|
+
* parent's `docComment` — already feeds the parent's symbol-level extraction.
|
|
470
|
+
* Tags on non-primary overloads are still dropped, but not silently: this
|
|
471
|
+
* function emits `misplaced_tag` for each (tag set and rationale on
|
|
472
|
+
* `MisplacedTagDiagnostic`).
|
|
461
473
|
*
|
|
462
474
|
* @param signatures - all call signatures from the type checker
|
|
463
475
|
* @param ctx - the extraction pass's context
|
|
@@ -487,10 +499,10 @@ const extractOverloads = (signatures, ctx, parentTsdoc, parentName) => {
|
|
|
487
499
|
overload.genericParams = decl.typeParameters.map(parseGenericParam);
|
|
488
500
|
}
|
|
489
501
|
// Detect primary overload by matching JSDoc text against the parent's.
|
|
490
|
-
// The
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
//
|
|
502
|
+
// The parent's JSDoc comes from the symbol's first declaration — the
|
|
503
|
+
// first overload signature, JSDoc or not — so that signature is the
|
|
504
|
+
// "primary": its symbol-scope tags already reach the parent through
|
|
505
|
+
// symbol-level extraction. Non-primary overloads with
|
|
494
506
|
// symbol-scope tags would silently lose them; surface as warnings instead.
|
|
495
507
|
const isPrimary = tsdoc?.text !== undefined &&
|
|
496
508
|
parentTsdoc?.text !== undefined &&
|
|
@@ -674,10 +686,10 @@ const isExternalProperty = (prop, isExternalFile) => originIsExternal(prop.getDe
|
|
|
674
686
|
* The one visibility rule, shared by the two ways a class's members reach
|
|
675
687
|
* output: `extractClassInfo` walking `node.members` at the class's own
|
|
676
688
|
* declaration, and `filterDocumentedProperties` projecting a class *type* at a
|
|
677
|
-
* structural container (`type X = LocalClass`,
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
* through
|
|
689
|
+
* structural container (`type X = LocalClass`, `type X = LocalGen<string>`).
|
|
690
|
+
* Held in one place so an alias over a class hides exactly what the class
|
|
691
|
+
* hides — the two paths disagreeing would leak `#` fields into `members`
|
|
692
|
+
* through the alias.
|
|
681
693
|
*
|
|
682
694
|
* `protected` is deliberately not private: it is part of the extension API a
|
|
683
695
|
* subclass author documents against. Only classes can declare either form —
|
|
@@ -725,10 +737,9 @@ export const isExternalSignature = (sig, isExternalFile) => originIsExternal(sig
|
|
|
725
737
|
* signatures. An empty entry is a contribution the checker synthesized, with
|
|
726
738
|
* no origin to test.
|
|
727
739
|
*
|
|
728
|
-
* The enumeration membership filters against, in one place
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
* nowhere and labeled nowhere.
|
|
740
|
+
* The enumeration membership filters against, held in one place so membership
|
|
741
|
+
* filtering and `externalTypes` labeling cover the same contribution kinds and
|
|
742
|
+
* can't disagree.
|
|
732
743
|
*/
|
|
733
744
|
const contributionOrigins = (type, checker) => [
|
|
734
745
|
...type.getProperties().map((prop) => prop.getDeclarations() ?? []),
|
|
@@ -802,6 +813,10 @@ const pushExternalTypeRef = (out, text) => {
|
|
|
802
813
|
* spelling already matches. That is also why the shared rule's export-specifier
|
|
803
814
|
* arm never fires here: it answers with the specifier's own published name,
|
|
804
815
|
* which is what an identifier reaching it was already spelled as.
|
|
816
|
+
*
|
|
817
|
+
* The substitution is one hop — the `ImportSpecifier`'s exported name — so a
|
|
818
|
+
* package's own `export {Foo as Bar}` and a local re-export chain both keep the
|
|
819
|
+
* importable name rather than walking to the declaration's own.
|
|
805
820
|
*/
|
|
806
821
|
const importedNameOf = (symbol, writtenText) => {
|
|
807
822
|
const name = specifierExportedName(symbol);
|
|
@@ -1195,11 +1210,11 @@ const collectExternalTypeRefs = (node, walk, out, depth, subst) => {
|
|
|
1195
1210
|
* local names itself, so a reference to a local alias — the generated
|
|
1196
1211
|
* `$$ComponentProps` the svelte2tsx props annotation names, or an author's own
|
|
1197
1212
|
* `type Props = …` — reaches the composition behind it without unwrapping the
|
|
1198
|
-
* node first. Unwrapping
|
|
1199
|
-
* covers: it
|
|
1200
|
-
* side, dropping the written type arguments, and
|
|
1201
|
-
* definition (mapped, conditional) with no node to attribute at
|
|
1202
|
-
* root reference is the name the contract says to record.
|
|
1213
|
+
* node first. Unwrapping would be lossy at exactly the position the leaf
|
|
1214
|
+
* fallback covers: it would replace a generic reference with the definition's
|
|
1215
|
+
* right-hand side, dropping the written type arguments, and leave an
|
|
1216
|
+
* untraversable definition (mapped, conditional) with no node to attribute at
|
|
1217
|
+
* all, where the root reference is the name the contract says to record.
|
|
1203
1218
|
*/
|
|
1204
1219
|
const resolveAnnotationTypeNode = (typeNode) => ts.isTypeNode(typeNode) ? typeNode : undefined;
|
|
1205
1220
|
/**
|
|
@@ -1256,6 +1271,12 @@ export const filterDocumentedProperties = (type, typeNode, checker, isExternalFi
|
|
|
1256
1271
|
* Only `extends` entries are passed by either caller: an interface has no
|
|
1257
1272
|
* other clause kind, and a class's `implements` adds no members.
|
|
1258
1273
|
*
|
|
1274
|
+
* Scoped to the processed declaration's own heritage clauses — the same node
|
|
1275
|
+
* `extends` and `members` come from — so on a merged interface only the
|
|
1276
|
+
* selected block contributes, while a reference to that interface elsewhere
|
|
1277
|
+
* descends every block. The three fields stay consistent with each other rather
|
|
1278
|
+
* than with the descent.
|
|
1279
|
+
*
|
|
1259
1280
|
* @mutates declaration - sets `externalTypes` when the walk finds any, left absent when not
|
|
1260
1281
|
*/
|
|
1261
1282
|
export const applyHeritageExternalTypes = (declaration, heritageTypes, ctx) => {
|
|
@@ -1426,7 +1447,7 @@ export const emitCallOrConstructSignature = (getSignatures, signatureKind, resol
|
|
|
1426
1447
|
file: loc.file,
|
|
1427
1448
|
line: loc.line,
|
|
1428
1449
|
column: loc.column,
|
|
1429
|
-
message: `Failed to analyze ${signatureKind} signatures for ${errorContext.kindLabel} "${declaration.name}": ${
|
|
1450
|
+
message: `Failed to analyze ${signatureKind} signatures for ${errorContext.kindLabel} "${declaration.name}": ${toErrorMessage(err)}`,
|
|
1430
1451
|
severity: 'warning',
|
|
1431
1452
|
functionName: declaration.name ?? '<default export>'
|
|
1432
1453
|
});
|
|
@@ -55,7 +55,7 @@ import type { TypeJson } from './types.js';
|
|
|
55
55
|
* - a union left with exactly one member after dropping `undefined` takes that
|
|
56
56
|
* member directly — it *is* the annotated type. Matters for a bare
|
|
57
57
|
* unconstrained type parameter (`c?: E`), where `getNonNullableType` can
|
|
58
|
-
* only answer `NonNullable<E>`
|
|
58
|
+
* only answer `NonNullable<E>`
|
|
59
59
|
* - every other union takes `getNonNullableType`, which rebuilds the union
|
|
60
60
|
* rather than picking a member (so a union of callables keeps its combined
|
|
61
61
|
* call signature) and preserves the alias symbol
|
|
@@ -83,11 +83,14 @@ export declare const namedSymbolName: (type: ts.Type) => string | undefined;
|
|
|
83
83
|
* type: no alias symbol (the checker still prints `type A = B` as `B`), no
|
|
84
84
|
* nominal symbol (interfaces/classes/enums print their own name), and not an
|
|
85
85
|
* interned terminal (`type A = string` and `type A = 'x'` carry no alias
|
|
86
|
-
* symbol either but print fine). True
|
|
87
|
-
*
|
|
86
|
+
* symbol either but print fine). True for the expansion-prone class the alias
|
|
87
|
+
* registry targets and the `alias_lost` diagnostic reports —
|
|
88
88
|
* indexed-access and conditional right-hand sides (`z.infer<typeof S>` et
|
|
89
89
|
* al.), whose resolution lands on a pre-existing interned type that TypeScript
|
|
90
90
|
* never retroactively stamps an alias symbol on.
|
|
91
|
+
*
|
|
92
|
+
* The exception is a lost alias over an array root: `namedSymbolName` names it
|
|
93
|
+
* `Array`, so the predicate is false and it never registers.
|
|
91
94
|
*/
|
|
92
95
|
export declare const isAliasLostType: (type: ts.Type) => boolean;
|
|
93
96
|
/**
|
|
@@ -116,6 +119,11 @@ export interface AliasRegistryEntry {
|
|
|
116
119
|
* per analysis cycle by `buildAliasRegistry` (`typescript-alias-registry.ts`);
|
|
117
120
|
* `undefined` wherever no pre-pass ran (registry recovery disabled, written
|
|
118
121
|
* recovery unaffected).
|
|
122
|
+
*
|
|
123
|
+
* Registry hits must be linkable: identity-exact matches against aliases the
|
|
124
|
+
* output documents. That's why `@nodocs` aliases and aliases in gated modules
|
|
125
|
+
* (`internal/`) never register, and why package aliases never do ("never name
|
|
126
|
+
* what the project didn't declare").
|
|
119
127
|
*/
|
|
120
128
|
export interface AliasRegistry {
|
|
121
129
|
/** Checker type identity → the winning alias (`compareStrings` name-then-module tie-break). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-extract-type-json.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/typescript-extract-type-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAAoB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,EAAE,CAAC,IAAI,EACb,SAAS,EAAE,CAAC,WAAW,EACvB,UAAU,OAAO,KACf;IAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAM3C,CAAC;AAEF;;;;;;GAMG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E,CAAC,WAAW,EACvB,eAAe,aAAa,GAAG,SAAS,EACxC,cAAc,EAAE,CAAC,QAAQ,KACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;CAiBhD,CAAC;AAkOF,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACtC,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,WAAW,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,eAAe,GAC3B,MAAM,EAAE,CAAC,IAAI,EACb,SAAS,EAAE,CAAC,WAAW,EACvB,eAAe,aAAa,GAAG,SAAS,EACxC,UAAU,OAAO,EACjB,UAAU,sBAAsB,KAC9B,QAAQ,GAAG,SAgCb,CAAC"}
|
|
@@ -109,7 +109,7 @@ const hasNullMember = (type) => type.isUnion()
|
|
|
109
109
|
* - a union left with exactly one member after dropping `undefined` takes that
|
|
110
110
|
* member directly — it *is* the annotated type. Matters for a bare
|
|
111
111
|
* unconstrained type parameter (`c?: E`), where `getNonNullableType` can
|
|
112
|
-
* only answer `NonNullable<E>`
|
|
112
|
+
* only answer `NonNullable<E>`
|
|
113
113
|
* - every other union takes `getNonNullableType`, which rebuilds the union
|
|
114
114
|
* rather than picking a member (so a union of callables keeps its combined
|
|
115
115
|
* call signature) and preserves the alias symbol
|
|
@@ -159,11 +159,14 @@ const isModuleObjectType = (type) => {
|
|
|
159
159
|
* type: no alias symbol (the checker still prints `type A = B` as `B`), no
|
|
160
160
|
* nominal symbol (interfaces/classes/enums print their own name), and not an
|
|
161
161
|
* interned terminal (`type A = string` and `type A = 'x'` carry no alias
|
|
162
|
-
* symbol either but print fine). True
|
|
163
|
-
*
|
|
162
|
+
* symbol either but print fine). True for the expansion-prone class the alias
|
|
163
|
+
* registry targets and the `alias_lost` diagnostic reports —
|
|
164
164
|
* indexed-access and conditional right-hand sides (`z.infer<typeof S>` et
|
|
165
165
|
* al.), whose resolution lands on a pre-existing interned type that TypeScript
|
|
166
166
|
* never retroactively stamps an alias symbol on.
|
|
167
|
+
*
|
|
168
|
+
* The exception is a lost alias over an array root: `namedSymbolName` names it
|
|
169
|
+
* `Array`, so the predicate is false and it never registers.
|
|
167
170
|
*/
|
|
168
171
|
export const isAliasLostType = (type) => type.aliasSymbol === undefined &&
|
|
169
172
|
namedSymbolName(type) === undefined &&
|
|
@@ -693,12 +696,12 @@ const buildTypeJson = (type, checker, depth, recovery, options = NO_OPTIONS) =>
|
|
|
693
696
|
}
|
|
694
697
|
return { kind: 'reference', name: type.aliasSymbol.name };
|
|
695
698
|
}
|
|
696
|
-
// one consult for every nameless object shape, tuples included
|
|
697
|
-
//
|
|
698
|
-
//
|
|
699
|
-
//
|
|
700
|
-
//
|
|
701
|
-
//
|
|
699
|
+
// one consult for every nameless object shape, tuples included — tuple
|
|
700
|
+
// references carry no symbol and recover at the cap, so consulting here
|
|
701
|
+
// keeps sub-cap tuples consistent with capped ones. Arrays and named
|
|
702
|
+
// instantiations decline via the nameless gate (`Array`/`ReadonlyArray`/
|
|
703
|
+
// the instantiation's own symbol), so their structural branches below
|
|
704
|
+
// still run
|
|
702
705
|
const recovered = recoveredReference(type, recovery, depth);
|
|
703
706
|
if (recovered)
|
|
704
707
|
return recovered;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
17
|
import ts from 'typescript';
|
|
18
|
-
import {
|
|
18
|
+
import { toErrorMessage } from './error.js';
|
|
19
19
|
import { parseComment } from './tsdoc.js';
|
|
20
20
|
import { resolveTypeInfo } from './typescript-extract-type-json.js';
|
|
21
21
|
import {} from './typescript-program.js';
|
|
@@ -91,7 +91,7 @@ const extractLocalIndexInfo = (nodeType, checker, isExternalFile, indexKind) =>
|
|
|
91
91
|
/**
|
|
92
92
|
* Resolve, emit, and diagnose a local index signature for a type alias.
|
|
93
93
|
*
|
|
94
|
-
* Wraps `
|
|
94
|
+
* Wraps `extractLocalIndexInfo` with the boilerplate shared by string and
|
|
95
95
|
* number kinds: push a `[key: string]` / `[key: number]` member when found,
|
|
96
96
|
* flip `partial: true` and add a `type_extraction_failed` diagnostic on
|
|
97
97
|
* checker errors. Pulled out of the call site to avoid copy-paste drift
|
|
@@ -131,7 +131,7 @@ const emitLocalIndexSignature = (declaration, nodeType, node, ctx, kind) => {
|
|
|
131
131
|
file: loc.file,
|
|
132
132
|
line: loc.line,
|
|
133
133
|
column: loc.column,
|
|
134
|
-
message: `Failed to extract ${kind} index signature for type "${declaration.name ?? '<default export>'}": ${
|
|
134
|
+
message: `Failed to extract ${kind} index signature for type "${declaration.name ?? '<default export>'}": ${toErrorMessage(err)}`,
|
|
135
135
|
severity: 'warning',
|
|
136
136
|
symbolName: declaration.name ?? '<default export>'
|
|
137
137
|
});
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
20
|
import ts from 'typescript';
|
|
21
|
-
import {
|
|
21
|
+
import { toErrorMessage } from './error.js';
|
|
22
22
|
import { parseComment, applyToDeclaration } from './tsdoc.js';
|
|
23
23
|
import { applyHeritageExternalTypes, emitCallOrConstructSignature, extractModifiers, getNodeLocation, getNonOptionalType, memberNameText, parseGenericParam, populateCallableMember, populatePropertyMember } from './typescript-extract-shared.js';
|
|
24
24
|
import { resolveTypeInfo } from './typescript-extract-type-json.js';
|
|
@@ -62,7 +62,7 @@ export const extractTypeInfo = (node, declaration, ctx) => {
|
|
|
62
62
|
file: loc.file,
|
|
63
63
|
line: loc.line,
|
|
64
64
|
column: loc.column,
|
|
65
|
-
message: `Failed to extract type for "${declaration.name}": ${
|
|
65
|
+
message: `Failed to extract type for "${declaration.name}": ${toErrorMessage(err)}`,
|
|
66
66
|
severity: 'warning',
|
|
67
67
|
symbolName: declaration.name ?? '<default export>'
|
|
68
68
|
});
|
|
@@ -135,7 +135,7 @@ export const extractTypeInfo = (node, declaration, ctx) => {
|
|
|
135
135
|
file: loc.file,
|
|
136
136
|
line: loc.line,
|
|
137
137
|
column: loc.column,
|
|
138
|
-
message: `Failed to extract type for interface property "${propName}" in "${declaration.name}": ${
|
|
138
|
+
message: `Failed to extract type for interface property "${propName}" in "${declaration.name}": ${toErrorMessage(err)}`,
|
|
139
139
|
severity: 'warning',
|
|
140
140
|
symbolName: propName
|
|
141
141
|
});
|
|
@@ -190,7 +190,7 @@ export const extractTypeInfo = (node, declaration, ctx) => {
|
|
|
190
190
|
file: loc.file,
|
|
191
191
|
line: loc.line,
|
|
192
192
|
column: loc.column,
|
|
193
|
-
message: `Failed to analyze interface method "${methodName}": ${
|
|
193
|
+
message: `Failed to analyze interface method "${methodName}": ${toErrorMessage(err)}`,
|
|
194
194
|
severity: 'warning',
|
|
195
195
|
functionName: methodName
|
|
196
196
|
});
|
|
@@ -229,7 +229,7 @@ export const extractTypeInfo = (node, declaration, ctx) => {
|
|
|
229
229
|
file: loc.file,
|
|
230
230
|
line: loc.line,
|
|
231
231
|
column: loc.column,
|
|
232
|
-
message: `Failed to extract type for index signature "${name}" in "${declaration.name}": ${
|
|
232
|
+
message: `Failed to extract type for index signature "${name}" in "${declaration.name}": ${toErrorMessage(err)}`,
|
|
233
233
|
severity: 'warning',
|
|
234
234
|
symbolName: name
|
|
235
235
|
});
|
|
@@ -289,7 +289,7 @@ export const extractEnumInfo = (node, declaration, ctx) => {
|
|
|
289
289
|
file: loc.file,
|
|
290
290
|
line: loc.line,
|
|
291
291
|
column: loc.column,
|
|
292
|
-
message: `Failed to extract type for "${declaration.name}": ${
|
|
292
|
+
message: `Failed to extract type for "${declaration.name}": ${toErrorMessage(err)}`,
|
|
293
293
|
severity: 'warning',
|
|
294
294
|
symbolName: declaration.name ?? '<default export>'
|
|
295
295
|
});
|
|
@@ -327,7 +327,7 @@ export const extractEnumInfo = (node, declaration, ctx) => {
|
|
|
327
327
|
file: loc.file,
|
|
328
328
|
line: loc.line,
|
|
329
329
|
column: loc.column,
|
|
330
|
-
message: `Failed to extract type for enum member "${memberName}" in "${declaration.name}": ${
|
|
330
|
+
message: `Failed to extract type for enum member "${memberName}" in "${declaration.name}": ${toErrorMessage(err)}`,
|
|
331
331
|
severity: 'warning',
|
|
332
332
|
symbolName: memberName
|
|
333
333
|
});
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* plumbing, `.svelte` module resolution):
|
|
6
6
|
*
|
|
7
7
|
* - `createAnalysisProgram` — one-shot `ts.Program` from a `ts.CompilerHost`.
|
|
8
|
-
* Lower-level escape hatch for power users
|
|
9
|
-
*
|
|
8
|
+
* Lower-level escape hatch for power users. Does not support incremental
|
|
9
|
+
* updates.
|
|
10
10
|
* - `createAnalysisLanguageService` — persistent `ts.LanguageService` with
|
|
11
11
|
* versioned `IScriptSnapshot`s. Incremental: subsequent `getProgram()` calls
|
|
12
12
|
* reuse parsed ASTs and checker state for unchanged files. Used by
|
|
@@ -54,7 +54,9 @@ export interface VirtualFileEntry {
|
|
|
54
54
|
content: string;
|
|
55
55
|
/**
|
|
56
56
|
* Overrides script-kind inference from the path's extension; `undefined`
|
|
57
|
-
* defers to the extension.
|
|
57
|
+
* defers to the extension. JS-lang Svelte virtuals set this to parse as JS
|
|
58
|
+
* despite their `.ts` suffix; no `allowJs` needed, since virtuals are
|
|
59
|
+
* host-served.
|
|
58
60
|
*/
|
|
59
61
|
scriptKind?: ts.ScriptKind;
|
|
60
62
|
}
|
|
@@ -219,7 +221,10 @@ export interface AnalysisLanguageService {
|
|
|
219
221
|
* resolution via `ts.resolveModuleName`) without the cost of building a full
|
|
220
222
|
* `ts.Program`.
|
|
221
223
|
*
|
|
222
|
-
*
|
|
224
|
+
* Each call globs the tsconfig `include` to build `rootFileNames`; reuse the
|
|
225
|
+
* result rather than calling per resolve.
|
|
226
|
+
*
|
|
227
|
+
* @throws Error if tsconfig.json (or the file named by `options.tsconfig`) is not found.
|
|
223
228
|
*/
|
|
224
229
|
export declare const loadTsconfig: (options?: LoadTsconfigOptions, log?: AnalysisLog) => {
|
|
225
230
|
compilerOptions: ts.CompilerOptions;
|
|
@@ -271,13 +276,23 @@ export declare const createAnalysisProgram: (options?: AnalysisProgramOptions, l
|
|
|
271
276
|
export declare const createAnalysisLanguageService: (options?: AnalysisLanguageServiceOptions, log?: AnalysisLog) => AnalysisLanguageService;
|
|
272
277
|
/**
|
|
273
278
|
* Predicate for determining whether a TypeScript source file is external to the project.
|
|
274
|
-
* Used by
|
|
275
|
-
*
|
|
279
|
+
* Used by external-contribution filtering (`filterDocumentedProperties` and the
|
|
280
|
+
* index/call-signature origin checks) and `externalTypes` attribution to separate
|
|
281
|
+
* project-authored contributions from library/framework ones.
|
|
276
282
|
*
|
|
277
|
-
*
|
|
278
|
-
* source root (e.g., `src/lib/`) are internal, everything else is external.
|
|
283
|
+
* Built by `createIsExternalFile`, which defines externality.
|
|
279
284
|
*/
|
|
280
285
|
export type IsExternalFile = (sourceFile: ts.SourceFile) => boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Create an `IsExternalFile` predicate from `ModuleSourceOptions`.
|
|
288
|
+
*
|
|
289
|
+
* A file is external if it is:
|
|
290
|
+
* - Outside the project root
|
|
291
|
+
* - Inside `node_modules/`
|
|
292
|
+
* - A `.d.ts` declaration file outside the source root (catches framework-generated
|
|
293
|
+
* declarations like `.svelte-kit/non-ambient.d.ts` while keeping user `.d.ts` files
|
|
294
|
+
* in the source tree)
|
|
295
|
+
*/
|
|
281
296
|
export declare const createIsExternalFile: (options: ModuleSourceOptions) => IsExternalFile;
|
|
282
297
|
/**
|
|
283
298
|
* Path-string counterpart of `IsExternalFile`, for call sites that hold a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-program.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/typescript-program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,MAAM,YA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