typedoc 0.26.11 → 0.27.0-beta.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/bin/package.json +3 -0
- package/bin/typedoc +1 -1
- package/dist/index.d.ts +23 -13
- package/dist/index.js +22 -81
- package/dist/lib/application-events.js +1 -4
- package/dist/lib/application.d.ts +26 -16
- package/dist/lib/application.js +222 -242
- package/dist/lib/cli.js +3 -40
- package/dist/lib/converter/comments/blockLexer.d.ts +1 -1
- package/dist/lib/converter/comments/blockLexer.js +24 -30
- package/dist/lib/converter/comments/declarationReference.js +10 -21
- package/dist/lib/converter/comments/declarationReferenceResolver.d.ts +2 -2
- package/dist/lib/converter/comments/declarationReferenceResolver.js +40 -36
- package/dist/lib/converter/comments/discovery.d.ts +4 -4
- package/dist/lib/converter/comments/discovery.js +154 -172
- package/dist/lib/converter/comments/index.d.ts +4 -4
- package/dist/lib/converter/comments/index.js +39 -50
- package/dist/lib/converter/comments/lexer.d.ts +1 -1
- package/dist/lib/converter/comments/lexer.js +2 -5
- package/dist/lib/converter/comments/lineLexer.d.ts +1 -1
- package/dist/lib/converter/comments/lineLexer.js +12 -15
- package/dist/lib/converter/comments/linkResolver.d.ts +2 -2
- package/dist/lib/converter/comments/linkResolver.js +14 -21
- package/dist/lib/converter/comments/parser.d.ts +6 -6
- package/dist/lib/converter/comments/parser.js +69 -96
- package/dist/lib/converter/comments/rawLexer.d.ts +1 -1
- package/dist/lib/converter/comments/rawLexer.js +13 -16
- package/dist/lib/converter/comments/tagName.js +1 -4
- package/dist/lib/converter/comments/textParser.d.ts +4 -4
- package/dist/lib/converter/comments/textParser.js +28 -30
- package/dist/lib/converter/components.d.ts +2 -3
- package/dist/lib/converter/components.js +2 -7
- package/dist/lib/converter/context.d.ts +9 -9
- package/dist/lib/converter/context.js +54 -44
- package/dist/lib/converter/convert-expression.js +16 -23
- package/dist/lib/converter/converter-events.d.ts +1 -0
- package/dist/lib/converter/converter-events.js +2 -4
- package/dist/lib/converter/converter.d.ts +16 -13
- package/dist/lib/converter/converter.js +210 -238
- package/dist/lib/converter/factories/index-signature.d.ts +1 -1
- package/dist/lib/converter/factories/index-signature.js +11 -17
- package/dist/lib/converter/factories/signature.d.ts +2 -2
- package/dist/lib/converter/factories/signature.js +95 -106
- package/dist/lib/converter/index.d.ts +6 -7
- package/dist/lib/converter/index.js +3 -11
- package/dist/lib/converter/jsdoc.d.ts +1 -1
- package/dist/lib/converter/jsdoc.js +34 -41
- package/dist/lib/converter/plugins/CategoryPlugin.d.ts +6 -21
- package/dist/lib/converter/plugins/CategoryPlugin.js +57 -139
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +3 -5
- package/dist/lib/converter/plugins/CommentPlugin.js +153 -163
- package/dist/lib/converter/plugins/GroupPlugin.d.ts +10 -9
- package/dist/lib/converter/plugins/GroupPlugin.js +87 -124
- package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +3 -5
- package/dist/lib/converter/plugins/ImplementsPlugin.js +255 -321
- package/dist/lib/converter/plugins/IncludePlugin.d.ts +11 -0
- package/dist/lib/converter/plugins/IncludePlugin.js +72 -0
- package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +4 -3
- package/dist/lib/converter/plugins/InheritDocPlugin.js +41 -72
- package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +5 -5
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +37 -58
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.d.ts +12 -0
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +49 -0
- package/dist/lib/converter/plugins/PackagePlugin.d.ts +4 -3
- package/dist/lib/converter/plugins/PackagePlugin.js +62 -111
- package/dist/lib/converter/plugins/SourcePlugin.d.ts +3 -5
- package/dist/lib/converter/plugins/SourcePlugin.js +69 -110
- package/dist/lib/converter/plugins/TypePlugin.d.ts +4 -6
- package/dist/lib/converter/plugins/TypePlugin.js +95 -158
- package/dist/lib/converter/plugins/index.d.ts +10 -9
- package/dist/lib/converter/plugins/index.js +10 -21
- package/dist/lib/converter/symbols.d.ts +1 -1
- package/dist/lib/converter/symbols.js +234 -227
- package/dist/lib/converter/types.d.ts +2 -2
- package/dist/lib/converter/types.js +252 -237
- package/dist/lib/converter/utils/nodes.js +5 -13
- package/dist/lib/converter/utils/reflections.d.ts +1 -1
- package/dist/lib/converter/utils/reflections.js +4 -7
- package/dist/lib/converter/utils/repository.d.ts +1 -1
- package/dist/lib/converter/utils/repository.js +103 -97
- package/dist/lib/converter/utils/symbols.js +3 -9
- package/dist/lib/internationalization/index.d.ts +3 -4
- package/dist/lib/internationalization/index.js +3 -8
- package/dist/lib/internationalization/internationalization.d.ts +5 -4
- package/dist/lib/internationalization/internationalization.js +97 -103
- package/dist/lib/internationalization/locale-utils.cjs +8 -0
- package/dist/lib/internationalization/locale-utils.d.cts +8 -0
- package/dist/lib/internationalization/locales/en.cjs +366 -2
- package/dist/lib/internationalization/locales/en.d.cts +339 -2
- package/dist/lib/internationalization/locales/jp.cjs +8 -11
- package/dist/lib/internationalization/locales/jp.d.cts +310 -1
- package/dist/lib/internationalization/locales/ko.cjs +7 -9
- package/dist/lib/internationalization/locales/ko.d.cts +223 -1
- package/dist/lib/internationalization/locales/zh.cjs +7 -10
- package/dist/lib/internationalization/locales/zh.d.cts +381 -1
- package/dist/lib/internationalization/translatable.d.ts +4 -327
- package/dist/lib/internationalization/translatable.js +2 -360
- package/dist/lib/models/FileRegistry.d.ts +20 -9
- package/dist/lib/models/FileRegistry.js +54 -45
- package/dist/lib/models/ReflectionCategory.d.ts +2 -2
- package/dist/lib/models/ReflectionCategory.js +16 -12
- package/dist/lib/models/ReflectionGroup.d.ts +3 -3
- package/dist/lib/models/ReflectionGroup.js +23 -14
- package/dist/lib/models/comments/comment.d.ts +23 -37
- package/dist/lib/models/comments/comment.js +388 -325
- package/dist/lib/models/comments/index.d.ts +2 -2
- package/dist/lib/models/comments/index.js +1 -6
- package/dist/lib/models/index.d.ts +7 -7
- package/dist/lib/models/index.js +7 -23
- package/dist/lib/models/reflections/ReflectionSymbolId.d.ts +2 -2
- package/dist/lib/models/reflections/ReflectionSymbolId.js +42 -34
- package/dist/lib/models/reflections/abstract.d.ts +17 -20
- package/dist/lib/models/reflections/abstract.js +249 -256
- package/dist/lib/models/reflections/container.d.ts +7 -7
- package/dist/lib/models/reflections/container.js +43 -16
- package/dist/lib/models/reflections/declaration.d.ts +15 -12
- package/dist/lib/models/reflections/declaration.js +150 -29
- package/dist/lib/models/reflections/document.d.ts +3 -3
- package/dist/lib/models/reflections/document.js +26 -13
- package/dist/lib/models/reflections/index.d.ts +15 -15
- package/dist/lib/models/reflections/index.js +12 -31
- package/dist/lib/models/reflections/kind.d.ts +1 -1
- package/dist/lib/models/reflections/kind.js +3 -6
- package/dist/lib/models/reflections/parameter.d.ts +5 -4
- package/dist/lib/models/reflections/parameter.js +11 -13
- package/dist/lib/models/reflections/project.d.ts +14 -9
- package/dist/lib/models/reflections/project.js +104 -56
- package/dist/lib/models/reflections/reference.d.ts +3 -3
- package/dist/lib/models/reflections/reference.js +6 -9
- package/dist/lib/models/reflections/signature.d.ts +8 -8
- package/dist/lib/models/reflections/signature.js +35 -14
- package/dist/lib/models/reflections/type-parameter.d.ts +5 -5
- package/dist/lib/models/reflections/type-parameter.js +9 -10
- package/dist/lib/models/reflections/utils.js +1 -4
- package/dist/lib/models/reflections/variant.d.ts +8 -7
- package/dist/lib/models/reflections/variant.js +1 -2
- package/dist/lib/models/sources/file.d.ts +2 -2
- package/dist/lib/models/sources/file.js +22 -5
- package/dist/lib/models/sources/index.d.ts +1 -1
- package/dist/lib/models/sources/index.js +1 -5
- package/dist/lib/models/types.d.ts +26 -13
- package/dist/lib/models/types.js +236 -151
- package/dist/lib/output/components.d.ts +5 -11
- package/dist/lib/output/components.js +84 -125
- package/dist/lib/output/events.d.ts +3 -3
- package/dist/lib/output/events.js +128 -94
- package/dist/lib/output/formatter.d.ts +84 -0
- package/dist/lib/output/formatter.js +619 -0
- package/dist/lib/output/index.d.ts +9 -8
- package/dist/lib/output/index.js +7 -19
- package/dist/lib/output/models/UrlMapping.d.ts +2 -2
- package/dist/lib/output/models/UrlMapping.js +4 -5
- package/dist/lib/output/output.d.ts +13 -0
- package/dist/lib/output/output.js +72 -0
- package/dist/lib/output/plugins/AssetsPlugin.d.ts +7 -8
- package/dist/lib/output/plugins/AssetsPlugin.js +62 -80
- package/dist/lib/output/plugins/IconsPlugin.d.ts +3 -2
- package/dist/lib/output/plugins/IconsPlugin.js +28 -84
- package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +9 -2
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +90 -96
- package/dist/lib/output/plugins/NavigationPlugin.d.ts +3 -2
- package/dist/lib/output/plugins/NavigationPlugin.js +22 -102
- package/dist/lib/output/plugins/SitemapPlugin.d.ts +3 -2
- package/dist/lib/output/plugins/SitemapPlugin.js +60 -120
- package/dist/lib/output/plugins/index.d.ts +6 -6
- package/dist/lib/output/plugins/index.js +6 -15
- package/dist/lib/output/renderer.d.ts +14 -13
- package/dist/lib/output/renderer.js +129 -185
- package/dist/lib/output/theme.d.ts +9 -5
- package/dist/lib/output/theme.js +14 -62
- package/dist/lib/output/themes/MarkedPlugin.d.ts +8 -9
- package/dist/lib/output/themes/MarkedPlugin.js +152 -117
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +17 -29
- package/dist/lib/output/themes/default/DefaultTheme.js +334 -310
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +63 -48
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +119 -95
- package/dist/lib/output/themes/default/Slugger.d.ts +13 -0
- package/dist/lib/output/themes/default/Slugger.js +46 -0
- package/dist/lib/output/themes/default/layouts/default.d.ts +5 -5
- package/dist/lib/output/themes/default/layouts/default.js +47 -36
- package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +2 -2
- package/dist/lib/output/themes/default/partials/anchor-icon.js +4 -7
- package/dist/lib/output/themes/default/partials/breadcrumb.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/breadcrumb.js +4 -8
- package/dist/lib/output/themes/default/partials/comment.d.ts +6 -4
- package/dist/lib/output/themes/default/partials/comment.js +52 -29
- package/dist/lib/output/themes/default/partials/footer.d.ts +2 -2
- package/dist/lib/output/themes/default/partials/footer.js +11 -14
- package/dist/lib/output/themes/default/partials/header.d.ts +4 -4
- package/dist/lib/output/themes/default/partials/header.js +9 -13
- package/dist/lib/output/themes/default/partials/hierarchy.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/hierarchy.js +9 -12
- package/dist/lib/output/themes/default/partials/icon.d.ts +4 -4
- package/dist/lib/output/themes/default/partials/icon.js +78 -73
- package/dist/lib/output/themes/default/partials/index.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/index.js +19 -22
- package/dist/lib/output/themes/default/partials/member.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/member.declaration.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/member.declaration.js +18 -61
- package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/member.getterSetter.js +10 -26
- package/dist/lib/output/themes/default/partials/member.js +19 -24
- package/dist/lib/output/themes/default/partials/member.signature.body.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/member.signature.body.js +17 -21
- package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +4 -7
- package/dist/lib/output/themes/default/partials/member.signature.title.js +8 -35
- package/dist/lib/output/themes/default/partials/member.signatures.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/member.signatures.js +9 -13
- package/dist/lib/output/themes/default/partials/member.sources.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/member.sources.js +13 -17
- package/dist/lib/output/themes/default/partials/members.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/members.js +10 -42
- package/dist/lib/output/themes/default/partials/moduleReflection.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/moduleReflection.js +62 -0
- package/dist/lib/output/themes/default/partials/navigation.d.ts +4 -4
- package/dist/lib/output/themes/default/partials/navigation.js +51 -62
- package/dist/lib/output/themes/default/partials/reflectionPreview.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +12 -15
- package/dist/lib/output/themes/default/partials/toolbar.d.ts +4 -4
- package/dist/lib/output/themes/default/partials/toolbar.js +16 -20
- package/dist/lib/output/themes/default/partials/type.d.ts +4 -6
- package/dist/lib/output/themes/default/partials/type.js +8 -388
- package/dist/lib/output/themes/default/partials/typeAndParent.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/typeAndParent.js +11 -15
- package/dist/lib/output/themes/default/partials/typeDetails.d.ts +8 -0
- package/dist/lib/output/themes/default/partials/typeDetails.js +221 -0
- package/dist/lib/output/themes/default/partials/typeParameters.d.ts +3 -3
- package/dist/lib/output/themes/default/partials/typeParameters.js +14 -17
- package/dist/lib/output/themes/default/templates/document.d.ts +4 -4
- package/dist/lib/output/themes/default/templates/document.js +3 -7
- package/dist/lib/output/themes/default/templates/hierarchy.d.ts +4 -4
- package/dist/lib/output/themes/default/templates/hierarchy.js +10 -13
- package/dist/lib/output/themes/default/templates/index.d.ts +4 -4
- package/dist/lib/output/themes/default/templates/index.js +3 -7
- package/dist/lib/output/themes/default/templates/reflection.d.ts +4 -4
- package/dist/lib/output/themes/default/templates/reflection.js +31 -34
- package/dist/lib/output/themes/lib.d.ts +17 -3
- package/dist/lib/output/themes/lib.js +110 -49
- package/dist/lib/serialization/components.d.ts +2 -5
- package/dist/lib/serialization/components.js +1 -2
- package/dist/lib/serialization/deserializer.d.ts +21 -7
- package/dist/lib/serialization/deserializer.js +138 -123
- package/dist/lib/serialization/events.d.ts +2 -2
- package/dist/lib/serialization/events.js +6 -5
- package/dist/lib/serialization/index.d.ts +5 -5
- package/dist/lib/serialization/index.js +4 -33
- package/dist/lib/serialization/schema.d.ts +8 -2
- package/dist/lib/serialization/schema.js +2 -2
- package/dist/lib/serialization/serializer.d.ts +11 -5
- package/dist/lib/serialization/serializer.js +32 -25
- package/dist/lib/utils/array.d.ts +3 -0
- package/dist/lib/utils/array.js +26 -27
- package/dist/lib/utils/component.d.ts +2 -44
- package/dist/lib/utils/component.js +10 -102
- package/dist/lib/utils/entry-point.d.ts +3 -4
- package/dist/lib/utils/entry-point.js +114 -85
- package/dist/lib/utils/enum.js +6 -14
- package/dist/lib/utils/events.js +6 -12
- package/dist/lib/utils/fs.js +50 -91
- package/dist/lib/utils/general.d.ts +2 -1
- package/dist/lib/utils/general.js +50 -40
- package/dist/lib/utils/highlighter.js +30 -57
- package/dist/lib/utils/hooks.js +7 -13
- package/dist/lib/utils/html-entities.d.ts +8926 -0
- package/dist/lib/utils/html-entities.js +2329 -0
- package/dist/lib/utils/html.d.ts +8 -0
- package/dist/lib/utils/html.js +81 -34
- package/dist/lib/utils/index.d.ts +22 -22
- package/dist/lib/utils/index.js +20 -91
- package/dist/lib/utils/jsx.d.ts +12 -5
- package/dist/lib/utils/jsx.elements.js +1 -4
- package/dist/lib/utils/jsx.js +53 -20
- package/dist/lib/utils/loggers.d.ts +3 -3
- package/dist/lib/utils/loggers.js +36 -46
- package/dist/lib/utils/map.js +6 -13
- package/dist/lib/utils/minimalSourceFile.js +5 -7
- package/dist/lib/utils/options/declaration.d.ts +33 -7
- package/dist/lib/utils/options/declaration.js +20 -22
- package/dist/lib/utils/options/defaults.d.ts +3 -2
- package/dist/lib/utils/options/defaults.js +18 -38
- package/dist/lib/utils/options/help.d.ts +2 -2
- package/dist/lib/utils/options/help.js +7 -10
- package/dist/lib/utils/options/index.d.ts +6 -6
- package/dist/lib/utils/options/index.js +4 -18
- package/dist/lib/utils/options/options.d.ts +8 -5
- package/dist/lib/utils/options/options.js +47 -71
- package/dist/lib/utils/options/readers/arguments.d.ts +2 -2
- package/dist/lib/utils/options/readers/arguments.js +15 -17
- package/dist/lib/utils/options/readers/index.d.ts +4 -4
- package/dist/lib/utils/options/readers/index.js +4 -11
- package/dist/lib/utils/options/readers/package-json.d.ts +3 -3
- package/dist/lib/utils/options/readers/package-json.js +15 -21
- package/dist/lib/utils/options/readers/tsconfig.d.ts +2 -2
- package/dist/lib/utils/options/readers/tsconfig.js +54 -63
- package/dist/lib/utils/options/readers/typedoc.d.ts +3 -3
- package/dist/lib/utils/options/readers/typedoc.js +44 -76
- package/dist/lib/utils/options/sources/index.d.ts +1 -1
- package/dist/lib/utils/options/sources/index.js +1 -5
- package/dist/lib/utils/options/sources/typedoc.d.ts +1 -1
- package/dist/lib/utils/options/sources/typedoc.js +220 -196
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +3 -3
- package/dist/lib/utils/options/tsdoc-defaults.js +16 -12
- package/dist/lib/utils/package-manifest.d.ts +1 -1
- package/dist/lib/utils/package-manifest.js +15 -19
- package/dist/lib/utils/paths.js +9 -15
- package/dist/lib/utils/perf.js +6 -11
- package/dist/lib/utils/plugins.d.ts +1 -1
- package/dist/lib/utils/plugins.js +7 -10
- package/dist/lib/utils/reflections.d.ts +1 -1
- package/dist/lib/utils/reflections.js +9 -12
- package/dist/lib/utils/set.js +2 -6
- package/dist/lib/utils/sort.d.ts +3 -3
- package/dist/lib/utils/sort.js +20 -24
- package/dist/lib/utils/tsconfig.d.ts +1 -1
- package/dist/lib/utils/tsconfig.js +13 -21
- package/dist/lib/utils/tsutils.d.ts +1 -1
- package/dist/lib/utils/tsutils.js +3 -30
- package/dist/lib/utils/validation.js +6 -12
- package/dist/lib/validation/documentation.d.ts +2 -2
- package/dist/lib/validation/documentation.js +26 -29
- package/dist/lib/validation/exports.d.ts +2 -2
- package/dist/lib/validation/exports.js +9 -11
- package/dist/lib/validation/links.d.ts +2 -2
- package/dist/lib/validation/links.js +4 -7
- package/dist/lib/validation/unusedMergeModuleWith.d.ts +3 -0
- package/dist/lib/validation/unusedMergeModuleWith.js +11 -0
- package/package.json +14 -11
- package/static/main.js +4 -4
- package/static/style.css +91 -2
- package/tsdoc.json +30 -0
- package/dist/lib/output/themes/default/partials/member.reference.d.ts +0 -4
- package/dist/lib/output/themes/default/partials/member.reference.js +0 -30
- package/dist/lib/output/themes/default/partials/parameter.d.ts +0 -4
- package/dist/lib/output/themes/default/partials/parameter.js +0 -79
- package/dist/lib/utils/html-entities.json +0 -2326
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const convert_expression_1 = require("./convert-expression");
|
|
12
|
-
const index_signature_1 = require("./factories/index-signature");
|
|
13
|
-
const signature_1 = require("./factories/signature");
|
|
14
|
-
const jsdoc_1 = require("./jsdoc");
|
|
15
|
-
const nodes_1 = require("./utils/nodes");
|
|
16
|
-
const reflections_1 = require("./utils/reflections");
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { DeclarationReflection, IntrinsicType, LiteralType, ReferenceReflection, ReflectionFlag, ReflectionKind, } from "../models/index.js";
|
|
4
|
+
import { getEnumFlags, hasAllFlags, hasAnyFlag, removeFlag, } from "../utils/enum.js";
|
|
5
|
+
import { convertDefaultValue } from "./convert-expression.js";
|
|
6
|
+
import { convertIndexSignatures } from "./factories/index-signature.js";
|
|
7
|
+
import { createConstructSignatureWithType, createSignature, createTypeParamReflection, } from "./factories/signature.js";
|
|
8
|
+
import { convertJsDocAlias, convertJsDocCallback } from "./jsdoc.js";
|
|
9
|
+
import { getHeritageTypes } from "./utils/nodes.js";
|
|
10
|
+
import { removeUndefined } from "./utils/reflections.js";
|
|
17
11
|
const symbolConverters = {
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
12
|
+
[ts.SymbolFlags.RegularEnum]: convertEnum,
|
|
13
|
+
[ts.SymbolFlags.ConstEnum]: convertEnum,
|
|
14
|
+
[ts.SymbolFlags.EnumMember]: convertEnumMember,
|
|
15
|
+
[ts.SymbolFlags.ValueModule]: convertNamespace,
|
|
16
|
+
[ts.SymbolFlags.NamespaceModule]: convertNamespace,
|
|
17
|
+
[ts.SymbolFlags.TypeAlias]: convertTypeAlias,
|
|
18
|
+
[ts.SymbolFlags.Function]: convertFunctionOrMethod,
|
|
19
|
+
[ts.SymbolFlags.Method]: convertFunctionOrMethod,
|
|
20
|
+
[ts.SymbolFlags.Interface]: convertClassOrInterface,
|
|
21
|
+
[ts.SymbolFlags.Property]: convertProperty,
|
|
22
|
+
[ts.SymbolFlags.Class]: convertClassOrInterface,
|
|
23
|
+
[ts.SymbolFlags.Constructor]: convertConstructor,
|
|
24
|
+
[ts.SymbolFlags.Alias]: convertAlias,
|
|
25
|
+
[ts.SymbolFlags.BlockScopedVariable]: convertVariable,
|
|
26
|
+
[ts.SymbolFlags.FunctionScopedVariable]: convertVariable,
|
|
27
|
+
[ts.SymbolFlags.ExportValue]: convertVariable,
|
|
28
|
+
[ts.SymbolFlags.GetAccessor]: convertAccessor,
|
|
29
|
+
[ts.SymbolFlags.SetAccessor]: convertAccessor,
|
|
36
30
|
};
|
|
37
31
|
const allConverterFlags = Object.keys(symbolConverters).reduce((v, k) => v | +k, 0);
|
|
38
32
|
// This is kind of a hack, born of resolving references by symbols instead
|
|
@@ -40,39 +34,39 @@ const allConverterFlags = Object.keys(symbolConverters).reduce((v, k) => v | +k,
|
|
|
40
34
|
const conversionOrder = [
|
|
41
35
|
// Do enums before namespaces so that @hidden on a namespace
|
|
42
36
|
// merged with an enum works properly.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
ts.SymbolFlags.RegularEnum,
|
|
38
|
+
ts.SymbolFlags.ConstEnum,
|
|
39
|
+
ts.SymbolFlags.EnumMember,
|
|
46
40
|
// Before type alias
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
41
|
+
ts.SymbolFlags.BlockScopedVariable,
|
|
42
|
+
ts.SymbolFlags.FunctionScopedVariable,
|
|
43
|
+
ts.SymbolFlags.ExportValue,
|
|
44
|
+
ts.SymbolFlags.Function, // Before NamespaceModule
|
|
45
|
+
ts.SymbolFlags.TypeAlias,
|
|
46
|
+
ts.SymbolFlags.Method,
|
|
47
|
+
ts.SymbolFlags.Interface,
|
|
48
|
+
ts.SymbolFlags.Property,
|
|
49
|
+
ts.SymbolFlags.Class,
|
|
50
|
+
ts.SymbolFlags.Constructor,
|
|
51
|
+
ts.SymbolFlags.Alias,
|
|
52
|
+
ts.SymbolFlags.GetAccessor,
|
|
53
|
+
ts.SymbolFlags.SetAccessor,
|
|
54
|
+
ts.SymbolFlags.ValueModule,
|
|
55
|
+
ts.SymbolFlags.NamespaceModule,
|
|
62
56
|
];
|
|
63
57
|
// Sanity check, if this fails a dev messed up.
|
|
64
58
|
for (const key of Object.keys(symbolConverters)) {
|
|
65
59
|
if (!Number.isInteger(Math.log2(+key))) {
|
|
66
|
-
throw new Error(`Symbol converter for key ${
|
|
60
|
+
throw new Error(`Symbol converter for key ${ts.SymbolFlags[+key]} does not specify a valid flag value.`);
|
|
67
61
|
}
|
|
68
62
|
if (!conversionOrder.includes(+key)) {
|
|
69
|
-
throw new Error(`Symbol converter for key ${
|
|
63
|
+
throw new Error(`Symbol converter for key ${ts.SymbolFlags[+key]} is not specified in conversionOrder`);
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
if (conversionOrder.reduce((a, b) => a | b, 0) !== allConverterFlags) {
|
|
73
67
|
throw new Error("conversionOrder contains a symbol flag that converters do not.");
|
|
74
68
|
}
|
|
75
|
-
function convertSymbol(context, symbol, exportSymbol) {
|
|
69
|
+
export function convertSymbol(context, symbol, exportSymbol) {
|
|
76
70
|
if (context.shouldIgnore(symbol)) {
|
|
77
71
|
return;
|
|
78
72
|
}
|
|
@@ -80,42 +74,42 @@ function convertSymbol(context, symbol, exportSymbol) {
|
|
|
80
74
|
// but aren't aliased symbols because `export *` was used.
|
|
81
75
|
const previous = context.project.getReflectionFromSymbol(symbol);
|
|
82
76
|
if (previous &&
|
|
83
|
-
previous.parent?.kindOf(
|
|
77
|
+
previous.parent?.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) {
|
|
84
78
|
createAlias(previous, context, symbol, exportSymbol);
|
|
85
79
|
return;
|
|
86
80
|
}
|
|
87
|
-
let flags =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
let flags = removeFlag(symbol.flags, ts.SymbolFlags.Transient |
|
|
82
|
+
ts.SymbolFlags.Assignment |
|
|
83
|
+
ts.SymbolFlags.Optional |
|
|
84
|
+
ts.SymbolFlags.Prototype);
|
|
91
85
|
// Declaration merging - the only type (excluding enum/enum, ns/ns, etc)
|
|
92
86
|
// that TD supports is merging a class and interface. All others are
|
|
93
87
|
// represented as multiple reflections
|
|
94
|
-
if (
|
|
95
|
-
flags =
|
|
88
|
+
if (hasAllFlags(symbol.flags, ts.SymbolFlags.Class)) {
|
|
89
|
+
flags = removeFlag(flags, ts.SymbolFlags.Interface | ts.SymbolFlags.Function);
|
|
96
90
|
}
|
|
97
91
|
// Kind of declaration merging... we treat this as a property with get/set signatures.
|
|
98
|
-
if (
|
|
99
|
-
flags =
|
|
92
|
+
if (hasAllFlags(symbol.flags, ts.SymbolFlags.GetAccessor)) {
|
|
93
|
+
flags = removeFlag(flags, ts.SymbolFlags.SetAccessor);
|
|
100
94
|
}
|
|
101
|
-
if (
|
|
95
|
+
if (hasAllFlags(symbol.flags, ts.SymbolFlags.NamespaceModule)) {
|
|
102
96
|
// This might be here if a namespace is declared several times.
|
|
103
97
|
// Or if it's a namespace-like thing defined on a function
|
|
104
98
|
// In the function case, it's important to remove ValueModule so that
|
|
105
99
|
// if we convert the children as properties of the function rather than as
|
|
106
100
|
// a separate namespace, we skip creating the namespace.
|
|
107
|
-
flags =
|
|
101
|
+
flags = removeFlag(flags, ts.SymbolFlags.ValueModule);
|
|
108
102
|
}
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
if (hasAnyFlag(symbol.flags, ts.SymbolFlags.Method |
|
|
104
|
+
ts.SymbolFlags.Interface |
|
|
105
|
+
ts.SymbolFlags.Class |
|
|
106
|
+
ts.SymbolFlags.Variable)) {
|
|
113
107
|
// This happens when someone declares an object with methods:
|
|
114
108
|
// { methodProperty() {} }
|
|
115
|
-
flags =
|
|
109
|
+
flags = removeFlag(flags, ts.SymbolFlags.Property);
|
|
116
110
|
}
|
|
117
|
-
for (const flag of
|
|
118
|
-
context.logger.verbose(`Missing converter for symbol: ${symbol.name} with flag ${
|
|
111
|
+
for (const flag of getEnumFlags(flags & ~allConverterFlags)) {
|
|
112
|
+
context.logger.verbose(`Missing converter for symbol: ${symbol.name} with flag ${ts.SymbolFlags[flag]}`);
|
|
119
113
|
}
|
|
120
114
|
// Note: This method does not allow skipping earlier converters.
|
|
121
115
|
// For now, this is fine... might not be flexible enough in the future.
|
|
@@ -134,48 +128,48 @@ function convertSymbols(context, symbols) {
|
|
|
134
128
|
}
|
|
135
129
|
}
|
|
136
130
|
function convertEnum(context, symbol, exportSymbol) {
|
|
137
|
-
const reflection = context.createDeclarationReflection(
|
|
138
|
-
if (symbol.flags &
|
|
139
|
-
reflection.setFlag(
|
|
131
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Enum, symbol, exportSymbol);
|
|
132
|
+
if (symbol.flags & ts.SymbolFlags.ConstEnum) {
|
|
133
|
+
reflection.setFlag(ReflectionFlag.Const);
|
|
140
134
|
}
|
|
141
135
|
context.finalizeDeclarationReflection(reflection);
|
|
142
136
|
convertSymbols(context.withScope(reflection), context.checker
|
|
143
137
|
.getExportsOfModule(symbol)
|
|
144
|
-
.filter((s) => s.flags &
|
|
138
|
+
.filter((s) => s.flags & ts.SymbolFlags.EnumMember));
|
|
145
139
|
}
|
|
146
140
|
function convertEnumMember(context, symbol, exportSymbol) {
|
|
147
|
-
const reflection = context.createDeclarationReflection(
|
|
141
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.EnumMember, symbol, exportSymbol);
|
|
148
142
|
const defaultValue = context.checker.getConstantValue(symbol.getDeclarations()[0]);
|
|
149
143
|
if (defaultValue !== undefined) {
|
|
150
|
-
reflection.type = new
|
|
144
|
+
reflection.type = new LiteralType(defaultValue);
|
|
151
145
|
}
|
|
152
146
|
else {
|
|
153
147
|
// We know this has to be a number, because computed values aren't allowed
|
|
154
148
|
// in string enums, so otherwise we would have to have the constant value
|
|
155
|
-
reflection.type = new
|
|
149
|
+
reflection.type = new IntrinsicType("number");
|
|
156
150
|
}
|
|
157
151
|
context.finalizeDeclarationReflection(reflection);
|
|
158
152
|
}
|
|
159
153
|
function convertNamespace(context, symbol, exportSymbol) {
|
|
160
|
-
let exportFlags =
|
|
154
|
+
let exportFlags = ts.SymbolFlags.ModuleMember;
|
|
161
155
|
// This can happen in JS land where "class" functions get tagged as a namespace too
|
|
162
156
|
if (symbol
|
|
163
157
|
.getDeclarations()
|
|
164
|
-
?.some((d) =>
|
|
158
|
+
?.some((d) => ts.isModuleDeclaration(d) || ts.isSourceFile(d)) !==
|
|
165
159
|
true) {
|
|
166
|
-
exportFlags =
|
|
167
|
-
if (
|
|
160
|
+
exportFlags = ts.SymbolFlags.ClassMember;
|
|
161
|
+
if (hasAnyFlag(symbol.flags, ts.SymbolFlags.Class)) {
|
|
168
162
|
return;
|
|
169
163
|
}
|
|
170
164
|
}
|
|
171
165
|
// #2364, @namespace on a variable might be merged with a namespace containing types.
|
|
172
166
|
const existingReflection = context.project.getReflectionFromSymbol(exportSymbol || symbol);
|
|
173
167
|
let reflection;
|
|
174
|
-
if (existingReflection?.kind ===
|
|
168
|
+
if (existingReflection?.kind === ReflectionKind.Namespace) {
|
|
175
169
|
reflection = existingReflection;
|
|
176
170
|
}
|
|
177
171
|
else {
|
|
178
|
-
reflection = context.createDeclarationReflection(
|
|
172
|
+
reflection = context.createDeclarationReflection(ReflectionKind.Namespace, symbol, exportSymbol);
|
|
179
173
|
context.finalizeDeclarationReflection(reflection);
|
|
180
174
|
}
|
|
181
175
|
convertSymbols(context.withScope(reflection), context.checker
|
|
@@ -185,38 +179,44 @@ function convertNamespace(context, symbol, exportSymbol) {
|
|
|
185
179
|
function convertTypeAlias(context, symbol, exportSymbol) {
|
|
186
180
|
const declaration = symbol
|
|
187
181
|
.getDeclarations()
|
|
188
|
-
?.find((d) =>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
(
|
|
193
|
-
if (
|
|
182
|
+
?.find((d) => ts.isTypeAliasDeclaration(d) ||
|
|
183
|
+
ts.isJSDocTypedefTag(d) ||
|
|
184
|
+
ts.isJSDocCallbackTag(d) ||
|
|
185
|
+
ts.isJSDocEnumTag(d));
|
|
186
|
+
assert(declaration);
|
|
187
|
+
if (ts.isTypeAliasDeclaration(declaration)) {
|
|
194
188
|
if (context
|
|
195
|
-
.getComment(symbol,
|
|
189
|
+
.getComment(symbol, ReflectionKind.TypeAlias)
|
|
196
190
|
?.hasModifier("@interface")) {
|
|
197
191
|
return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
|
|
198
192
|
}
|
|
199
|
-
const reflection = context.createDeclarationReflection(
|
|
200
|
-
|
|
193
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
194
|
+
if (reflection.comment?.hasModifier("@useDeclaredType")) {
|
|
195
|
+
reflection.comment.removeModifier("@useDeclaredType");
|
|
196
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getDeclaredTypeOfSymbol(symbol));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), declaration.type);
|
|
200
|
+
}
|
|
201
201
|
if (reflection.type.type === "union") {
|
|
202
202
|
attachUnionComments(context, declaration, reflection.type);
|
|
203
203
|
}
|
|
204
204
|
context.finalizeDeclarationReflection(reflection);
|
|
205
205
|
// Do this after finalization so that the CommentPlugin can get @typeParam tags
|
|
206
206
|
// from the parent comment. Ugly, but works for now. Should be cleaned up eventually.
|
|
207
|
-
reflection.typeParameters = declaration.typeParameters?.map((param) =>
|
|
207
|
+
reflection.typeParameters = declaration.typeParameters?.map((param) => createTypeParamReflection(param, context.withScope(reflection)));
|
|
208
208
|
}
|
|
209
|
-
else if (
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
else if (ts.isJSDocTypedefTag(declaration) ||
|
|
210
|
+
ts.isJSDocEnumTag(declaration)) {
|
|
211
|
+
convertJsDocAlias(context, symbol, declaration, exportSymbol);
|
|
212
212
|
}
|
|
213
213
|
else {
|
|
214
|
-
|
|
214
|
+
convertJsDocCallback(context, symbol, declaration, exportSymbol);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
function attachUnionComments(context, declaration, union) {
|
|
218
218
|
const list = declaration.type.getChildAt(0);
|
|
219
|
-
if (list.kind !==
|
|
219
|
+
if (list.kind !== ts.SyntaxKind.SyntaxList)
|
|
220
220
|
return;
|
|
221
221
|
let unionIndex = 0;
|
|
222
222
|
for (const child of list.getChildren()) {
|
|
@@ -228,17 +228,17 @@ function attachUnionComments(context, declaration, union) {
|
|
|
228
228
|
union.elementSummaries ||= Array.from({ length: union.types.length }, () => []);
|
|
229
229
|
union.elementSummaries[unionIndex] = comment.summary;
|
|
230
230
|
}
|
|
231
|
-
if (child.kind !==
|
|
231
|
+
if (child.kind !== ts.SyntaxKind.BarToken) {
|
|
232
232
|
++unionIndex;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
function convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration) {
|
|
237
|
-
const reflection = context.createDeclarationReflection(
|
|
237
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Interface, symbol, exportSymbol);
|
|
238
238
|
context.finalizeDeclarationReflection(reflection);
|
|
239
239
|
const rc = context.withScope(reflection);
|
|
240
240
|
const type = context.checker.getTypeAtLocation(declaration);
|
|
241
|
-
if (type.getFlags() &
|
|
241
|
+
if (type.getFlags() & ts.TypeFlags.Union) {
|
|
242
242
|
context.logger.warn(context.i18n.converting_union_as_interface(), declaration);
|
|
243
243
|
}
|
|
244
244
|
// Interfaces have properties
|
|
@@ -247,51 +247,51 @@ function convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration)
|
|
|
247
247
|
if (declaration.typeParameters) {
|
|
248
248
|
reflection.typeParameters = declaration.typeParameters.map((param) => {
|
|
249
249
|
const declaration = param.symbol?.declarations?.[0];
|
|
250
|
-
(
|
|
251
|
-
return
|
|
250
|
+
assert(declaration && ts.isTypeParameterDeclaration(declaration));
|
|
251
|
+
return createTypeParamReflection(declaration, rc);
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
// And maybe call signatures
|
|
255
255
|
context.checker
|
|
256
|
-
.getSignaturesOfType(type,
|
|
257
|
-
.forEach((sig) =>
|
|
256
|
+
.getSignaturesOfType(type, ts.SignatureKind.Call)
|
|
257
|
+
.forEach((sig) => createSignature(rc, ReflectionKind.CallSignature, sig, symbol));
|
|
258
258
|
// And maybe constructor signatures
|
|
259
259
|
convertConstructSignatures(rc, symbol);
|
|
260
260
|
// And finally, index signatures
|
|
261
|
-
|
|
261
|
+
convertIndexSignatures(rc, symbol);
|
|
262
262
|
}
|
|
263
263
|
function convertFunctionOrMethod(context, symbol, exportSymbol) {
|
|
264
264
|
// Can't just check method flag because this might be called for properties as well
|
|
265
265
|
// This will *NOT* be called for variables that look like functions, they need a special case.
|
|
266
266
|
const isMethod = !!(symbol.flags &
|
|
267
|
-
(
|
|
267
|
+
(ts.SymbolFlags.Property | ts.SymbolFlags.Method));
|
|
268
268
|
if (!isMethod) {
|
|
269
|
-
const comment = context.getComment(symbol,
|
|
269
|
+
const comment = context.getComment(symbol, ReflectionKind.Function);
|
|
270
270
|
if (comment?.hasModifier("@class")) {
|
|
271
271
|
return convertSymbolAsClass(context, symbol, exportSymbol);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
const declarations = symbol.getDeclarations()?.filter(
|
|
274
|
+
const declarations = symbol.getDeclarations()?.filter(ts.isFunctionLike) ?? [];
|
|
275
275
|
// Don't do anything if we inherited this method and it is private.
|
|
276
276
|
if (isMethod &&
|
|
277
277
|
isInherited(context, symbol) &&
|
|
278
278
|
declarations.length > 0 &&
|
|
279
|
-
|
|
279
|
+
hasAllFlags(ts.getCombinedModifierFlags(declarations[0]), ts.ModifierFlags.Private)) {
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
282
|
const locationDeclaration = symbol.parent
|
|
283
283
|
?.getDeclarations()
|
|
284
|
-
?.find((d) =>
|
|
284
|
+
?.find((d) => ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) ??
|
|
285
285
|
symbol.parent?.getDeclarations()?.[0]?.getSourceFile() ??
|
|
286
286
|
symbol.getDeclarations()?.[0]?.getSourceFile();
|
|
287
|
-
(
|
|
287
|
+
assert(locationDeclaration, "Missing declaration context");
|
|
288
288
|
const type = context.checker.getTypeOfSymbolAtLocation(symbol, locationDeclaration);
|
|
289
289
|
// Need to get the non nullable type because interface methods might be declared
|
|
290
290
|
// with a question token. See GH1490.
|
|
291
291
|
const signatures = type.getNonNullableType().getCallSignatures();
|
|
292
|
-
const reflection = context.createDeclarationReflection(context.scope.kindOf(
|
|
293
|
-
?
|
|
294
|
-
:
|
|
292
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.MethodContainer)
|
|
293
|
+
? ReflectionKind.Method
|
|
294
|
+
: ReflectionKind.Function, symbol, exportSymbol, void 0);
|
|
295
295
|
if (symbol.declarations?.length && isMethod) {
|
|
296
296
|
// All method signatures must have the same modifier flags.
|
|
297
297
|
setModifiers(symbol, symbol.declarations[0], reflection);
|
|
@@ -299,34 +299,34 @@ function convertFunctionOrMethod(context, symbol, exportSymbol) {
|
|
|
299
299
|
context.finalizeDeclarationReflection(reflection);
|
|
300
300
|
const scope = context.withScope(reflection);
|
|
301
301
|
for (const sig of signatures) {
|
|
302
|
-
|
|
302
|
+
createSignature(scope, ReflectionKind.CallSignature, sig, symbol);
|
|
303
303
|
}
|
|
304
304
|
return convertFunctionProperties(scope, symbol, type);
|
|
305
305
|
}
|
|
306
306
|
// getDeclaredTypeOfSymbol gets the INSTANCE type
|
|
307
307
|
// getTypeOfSymbolAtLocation gets the STATIC type
|
|
308
308
|
function convertClassOrInterface(context, symbol, exportSymbol) {
|
|
309
|
-
const reflection = context.createDeclarationReflection(
|
|
310
|
-
?
|
|
311
|
-
:
|
|
309
|
+
const reflection = context.createDeclarationReflection(ts.SymbolFlags.Class & symbol.flags
|
|
310
|
+
? ReflectionKind.Class
|
|
311
|
+
: ReflectionKind.Interface, symbol, exportSymbol, void 0);
|
|
312
312
|
const classDeclaration = symbol
|
|
313
313
|
.getDeclarations()
|
|
314
|
-
?.find((d) =>
|
|
314
|
+
?.find((d) => ts.isClassDeclaration(d) || ts.isFunctionDeclaration(d));
|
|
315
315
|
if (classDeclaration)
|
|
316
316
|
setModifiers(symbol, classDeclaration, reflection);
|
|
317
317
|
const reflectionContext = context.withScope(reflection);
|
|
318
318
|
reflectionContext.convertingClassOrInterface = true;
|
|
319
319
|
const instanceType = context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
320
|
-
(
|
|
320
|
+
assert(instanceType.isClassOrInterface());
|
|
321
321
|
// We might do some inheritance - do this first so that it's set when converting properties
|
|
322
322
|
const declarations = symbol
|
|
323
323
|
.getDeclarations()
|
|
324
|
-
?.filter((d) =>
|
|
325
|
-
const extendedTypes =
|
|
324
|
+
?.filter((d) => ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) ?? [];
|
|
325
|
+
const extendedTypes = getHeritageTypes(declarations, ts.SyntaxKind.ExtendsKeyword).map((t) => context.converter.convertType(reflectionContext, t));
|
|
326
326
|
if (extendedTypes.length) {
|
|
327
327
|
reflection.extendedTypes = extendedTypes;
|
|
328
328
|
}
|
|
329
|
-
const implementedTypes =
|
|
329
|
+
const implementedTypes = getHeritageTypes(declarations, ts.SyntaxKind.ImplementsKeyword).map((t) => context.converter.convertType(reflectionContext, t));
|
|
330
330
|
if (implementedTypes.length) {
|
|
331
331
|
reflection.implementedTypes = implementedTypes;
|
|
332
332
|
}
|
|
@@ -338,13 +338,13 @@ function convertClassOrInterface(context, symbol, exportSymbol) {
|
|
|
338
338
|
for (const prop of context.checker.getPropertiesOfType(staticType)) {
|
|
339
339
|
// Don't convert namespace members, or the prototype here.
|
|
340
340
|
if (prop.flags &
|
|
341
|
-
(
|
|
341
|
+
(ts.SymbolFlags.ModuleMember | ts.SymbolFlags.Prototype))
|
|
342
342
|
continue;
|
|
343
343
|
convertSymbol(reflectionContext, prop);
|
|
344
344
|
}
|
|
345
345
|
reflectionContext.shouldBeStatic = false;
|
|
346
346
|
const ctors = staticType.getConstructSignatures();
|
|
347
|
-
const constructMember = reflectionContext.createDeclarationReflection(
|
|
347
|
+
const constructMember = reflectionContext.createDeclarationReflection(ReflectionKind.Constructor, ctors[0]?.declaration?.symbol, void 0, "constructor");
|
|
348
348
|
// Modifiers are the same for all constructors
|
|
349
349
|
if (ctors.length && ctors[0].declaration) {
|
|
350
350
|
setModifiers(symbol, ctors[0].declaration, constructMember);
|
|
@@ -352,7 +352,7 @@ function convertClassOrInterface(context, symbol, exportSymbol) {
|
|
|
352
352
|
context.finalizeDeclarationReflection(constructMember);
|
|
353
353
|
const constructContext = reflectionContext.withScope(constructMember);
|
|
354
354
|
ctors.forEach((sig) => {
|
|
355
|
-
|
|
355
|
+
createSignature(constructContext, ReflectionKind.ConstructorSignature, sig, symbol);
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
// Classes/interfaces usually just have properties...
|
|
@@ -361,119 +361,122 @@ function convertClassOrInterface(context, symbol, exportSymbol) {
|
|
|
361
361
|
if (instanceType.typeParameters) {
|
|
362
362
|
reflection.typeParameters = instanceType.typeParameters.map((param) => {
|
|
363
363
|
const declaration = param.symbol.declarations?.[0];
|
|
364
|
-
(
|
|
365
|
-
return
|
|
364
|
+
assert(declaration && ts.isTypeParameterDeclaration(declaration));
|
|
365
|
+
return createTypeParamReflection(declaration, reflectionContext);
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
368
|
// Interfaces might also have call signatures
|
|
369
369
|
// Classes might too, because of declaration merging
|
|
370
370
|
context.checker
|
|
371
|
-
.getSignaturesOfType(instanceType,
|
|
372
|
-
.forEach((sig) =>
|
|
371
|
+
.getSignaturesOfType(instanceType, ts.SignatureKind.Call)
|
|
372
|
+
.forEach((sig) => createSignature(reflectionContext, ReflectionKind.CallSignature, sig, symbol));
|
|
373
373
|
// We also might have constructor signatures
|
|
374
374
|
// This is potentially a problem with classes having multiple "constructor" members...
|
|
375
375
|
// but nobody has complained yet.
|
|
376
376
|
convertConstructSignatures(reflectionContext, symbol);
|
|
377
377
|
// And finally, index signatures
|
|
378
|
-
|
|
378
|
+
convertIndexSignatures(reflectionContext, symbol);
|
|
379
379
|
// Normally this shouldn't matter, unless someone did something with skipLibCheck on.
|
|
380
|
-
return
|
|
380
|
+
return ts.SymbolFlags.Alias;
|
|
381
381
|
}
|
|
382
382
|
function convertProperty(context, symbol, exportSymbol) {
|
|
383
383
|
// This might happen if we're converting a function-module created with Object.assign
|
|
384
384
|
// or `export default () => {}`
|
|
385
|
-
if (context.scope.kindOf(
|
|
385
|
+
if (context.scope.kindOf(ReflectionKind.VariableContainer)) {
|
|
386
386
|
return convertVariable(context, symbol, exportSymbol);
|
|
387
387
|
}
|
|
388
388
|
const declarations = symbol.getDeclarations() ?? [];
|
|
389
389
|
// Don't do anything if we inherited this property and it is private.
|
|
390
390
|
if (isInherited(context, symbol) &&
|
|
391
391
|
declarations.length > 0 &&
|
|
392
|
-
|
|
392
|
+
hasAllFlags(ts.getCombinedModifierFlags(declarations[0]), ts.ModifierFlags.Private)) {
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
395
|
// Special case: We pretend properties are methods if they look like methods.
|
|
396
396
|
// This happens with mixins / weird inheritance.
|
|
397
397
|
if (declarations.length &&
|
|
398
|
-
declarations.every((decl) =>
|
|
398
|
+
declarations.every((decl) => ts.isMethodSignature(decl) || ts.isMethodDeclaration(decl))) {
|
|
399
399
|
return convertFunctionOrMethod(context, symbol, exportSymbol);
|
|
400
400
|
}
|
|
401
401
|
if (declarations.length === 1) {
|
|
402
402
|
const declaration = declarations[0];
|
|
403
403
|
// Special case: "arrow methods" should be treated as methods.
|
|
404
|
-
if (
|
|
404
|
+
if (ts.isPropertyDeclaration(declaration) &&
|
|
405
405
|
!declaration.type &&
|
|
406
406
|
declaration.initializer &&
|
|
407
|
-
|
|
407
|
+
ts.isArrowFunction(declaration.initializer)) {
|
|
408
408
|
return convertArrowAsMethod(context, symbol, declaration.initializer, exportSymbol);
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
|
-
const reflection = context.createDeclarationReflection(context.scope.kindOf(
|
|
412
|
-
?
|
|
413
|
-
:
|
|
411
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.VariableContainer)
|
|
412
|
+
? ReflectionKind.Variable
|
|
413
|
+
: ReflectionKind.Property, symbol, exportSymbol);
|
|
414
414
|
const declaration = symbol.getDeclarations()?.[0];
|
|
415
415
|
let parameterType;
|
|
416
416
|
if (declaration &&
|
|
417
|
-
(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
if (!
|
|
423
|
-
!
|
|
417
|
+
(ts.isPropertyDeclaration(declaration) ||
|
|
418
|
+
ts.isPropertySignature(declaration) ||
|
|
419
|
+
ts.isParameter(declaration) ||
|
|
420
|
+
ts.isPropertyAccessExpression(declaration) ||
|
|
421
|
+
ts.isPropertyAssignment(declaration))) {
|
|
422
|
+
if (!ts.isPropertyAccessExpression(declaration) &&
|
|
423
|
+
!ts.isPropertyAssignment(declaration)) {
|
|
424
424
|
parameterType = declaration.type;
|
|
425
425
|
}
|
|
426
426
|
setModifiers(symbol, declaration, reflection);
|
|
427
427
|
}
|
|
428
|
-
|
|
428
|
+
else {
|
|
429
|
+
setSymbolModifiers(symbol, reflection);
|
|
430
|
+
}
|
|
431
|
+
reflection.defaultValue = declaration && convertDefaultValue(declaration);
|
|
429
432
|
reflection.type = context.converter.convertType(context.withScope(reflection), (context.convertingTypeNode ? parameterType : void 0) ??
|
|
430
433
|
context.checker.getTypeOfSymbol(symbol));
|
|
431
434
|
if (reflection.flags.isOptional) {
|
|
432
|
-
reflection.type =
|
|
435
|
+
reflection.type = removeUndefined(reflection.type);
|
|
433
436
|
}
|
|
434
437
|
context.finalizeDeclarationReflection(reflection);
|
|
435
438
|
}
|
|
436
439
|
function convertArrowAsMethod(context, symbol, arrow, exportSymbol) {
|
|
437
|
-
const reflection = context.createDeclarationReflection(
|
|
440
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Method, symbol, exportSymbol, void 0);
|
|
438
441
|
setModifiers(symbol, arrow.parent, reflection);
|
|
439
442
|
context.finalizeDeclarationReflection(reflection);
|
|
440
443
|
const rc = context.withScope(reflection);
|
|
441
444
|
const locationDeclaration = symbol.parent
|
|
442
445
|
?.getDeclarations()
|
|
443
|
-
?.find((d) =>
|
|
446
|
+
?.find((d) => ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) ??
|
|
444
447
|
symbol.parent?.getDeclarations()?.[0]?.getSourceFile() ??
|
|
445
448
|
symbol.getDeclarations()?.[0]?.getSourceFile();
|
|
446
|
-
(
|
|
449
|
+
assert(locationDeclaration, "Missing declaration context");
|
|
447
450
|
const type = context.checker.getTypeOfSymbolAtLocation(symbol, locationDeclaration);
|
|
448
451
|
const signatures = type.getNonNullableType().getCallSignatures();
|
|
449
|
-
(
|
|
450
|
-
|
|
452
|
+
assert(signatures.length, "Missing signatures");
|
|
453
|
+
createSignature(rc, ReflectionKind.CallSignature, signatures[0], symbol, arrow);
|
|
451
454
|
}
|
|
452
455
|
function convertConstructor(context, symbol) {
|
|
453
|
-
const reflection = context.createDeclarationReflection(
|
|
456
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Constructor, symbol, void 0, "constructor");
|
|
454
457
|
context.finalizeDeclarationReflection(reflection);
|
|
455
458
|
const reflectionContext = context.withScope(reflection);
|
|
456
|
-
const declarations = symbol.getDeclarations()?.filter(
|
|
459
|
+
const declarations = symbol.getDeclarations()?.filter(ts.isConstructorDeclaration) ?? [];
|
|
457
460
|
const signatures = declarations.map((decl) => {
|
|
458
461
|
const sig = context.checker.getSignatureFromDeclaration(decl);
|
|
459
|
-
(
|
|
462
|
+
assert(sig);
|
|
460
463
|
return sig;
|
|
461
464
|
});
|
|
462
465
|
for (const sig of signatures) {
|
|
463
|
-
|
|
466
|
+
createSignature(reflectionContext, ReflectionKind.ConstructorSignature, sig, symbol);
|
|
464
467
|
}
|
|
465
468
|
}
|
|
466
469
|
function convertConstructSignatures(context, symbol) {
|
|
467
470
|
const type = context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
468
471
|
// These get added as a "constructor" member of this interface. This is a problem... but nobody
|
|
469
472
|
// has complained yet. We really ought to have a constructSignatures property on the reflection instead.
|
|
470
|
-
const constructSignatures = context.checker.getSignaturesOfType(type,
|
|
473
|
+
const constructSignatures = context.checker.getSignaturesOfType(type, ts.SignatureKind.Construct);
|
|
471
474
|
if (constructSignatures.length) {
|
|
472
|
-
const constructMember = new
|
|
475
|
+
const constructMember = new DeclarationReflection("constructor", ReflectionKind.Constructor, context.scope);
|
|
473
476
|
context.postReflectionCreation(constructMember, symbol, void 0);
|
|
474
477
|
context.finalizeDeclarationReflection(constructMember);
|
|
475
478
|
const constructContext = context.withScope(constructMember);
|
|
476
|
-
constructSignatures.forEach((sig) =>
|
|
479
|
+
constructSignatures.forEach((sig) => createSignature(constructContext, ReflectionKind.ConstructorSignature, sig, symbol));
|
|
477
480
|
}
|
|
478
481
|
}
|
|
479
482
|
function convertAlias(context, symbol, exportSymbol) {
|
|
@@ -490,13 +493,13 @@ function createAlias(target, context, symbol, exportSymbol) {
|
|
|
490
493
|
if (context.converter.excludeReferences)
|
|
491
494
|
return;
|
|
492
495
|
// We already have this. Create a reference.
|
|
493
|
-
const ref = new
|
|
496
|
+
const ref = new ReferenceReflection(exportSymbol?.name ?? symbol.name, target, context.scope);
|
|
494
497
|
context.postReflectionCreation(ref, symbol, exportSymbol);
|
|
495
498
|
context.finalizeDeclarationReflection(ref);
|
|
496
499
|
}
|
|
497
500
|
function convertVariable(context, symbol, exportSymbol) {
|
|
498
501
|
const declaration = symbol.getDeclarations()?.[0];
|
|
499
|
-
const comment = context.getComment(symbol,
|
|
502
|
+
const comment = context.getComment(symbol, ReflectionKind.Variable);
|
|
500
503
|
const type = declaration
|
|
501
504
|
? context.checker.getTypeOfSymbolAtLocation(symbol, declaration)
|
|
502
505
|
: context.checker.getTypeOfSymbol(symbol);
|
|
@@ -514,22 +517,22 @@ function convertVariable(context, symbol, exportSymbol) {
|
|
|
514
517
|
!type.getConstructSignatures().length) {
|
|
515
518
|
return convertVariableAsFunction(context, symbol, exportSymbol);
|
|
516
519
|
}
|
|
517
|
-
const reflection = context.createDeclarationReflection(context.scope.kindOf(
|
|
518
|
-
?
|
|
519
|
-
:
|
|
520
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.VariableContainer)
|
|
521
|
+
? ReflectionKind.Variable
|
|
522
|
+
: ReflectionKind.Property, symbol, exportSymbol);
|
|
520
523
|
let typeNode;
|
|
521
|
-
if (declaration &&
|
|
524
|
+
if (declaration && ts.isVariableDeclaration(declaration)) {
|
|
522
525
|
// Otherwise we might have destructuring
|
|
523
526
|
typeNode = declaration.type;
|
|
524
527
|
}
|
|
525
528
|
reflection.type = context.converter.convertType(context.withScope(reflection), typeNode ?? type);
|
|
526
529
|
setModifiers(symbol, declaration, reflection);
|
|
527
|
-
reflection.defaultValue =
|
|
530
|
+
reflection.defaultValue = convertDefaultValue(declaration);
|
|
528
531
|
context.finalizeDeclarationReflection(reflection);
|
|
529
|
-
return
|
|
532
|
+
return ts.SymbolFlags.Property;
|
|
530
533
|
}
|
|
531
534
|
function isEnumLike(checker, type, location) {
|
|
532
|
-
if (!location || !
|
|
535
|
+
if (!location || !hasAllFlags(type.flags, ts.TypeFlags.Object)) {
|
|
533
536
|
return false;
|
|
534
537
|
}
|
|
535
538
|
return type.getProperties().every((prop) => {
|
|
@@ -538,51 +541,51 @@ function isEnumLike(checker, type, location) {
|
|
|
538
541
|
});
|
|
539
542
|
}
|
|
540
543
|
function isValidEnumProperty(type) {
|
|
541
|
-
return
|
|
544
|
+
return hasAnyFlag(type.flags, ts.TypeFlags.NumberLike | ts.TypeFlags.StringLike);
|
|
542
545
|
}
|
|
543
546
|
function convertVariableAsEnum(context, symbol, exportSymbol) {
|
|
544
|
-
const reflection = context.createDeclarationReflection(
|
|
547
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Enum, symbol, exportSymbol);
|
|
545
548
|
context.finalizeDeclarationReflection(reflection);
|
|
546
549
|
const rc = context.withScope(reflection);
|
|
547
|
-
const declaration = symbol.declarations
|
|
550
|
+
const declaration = symbol.declarations.find(ts.isVariableDeclaration);
|
|
548
551
|
const type = context.checker.getTypeAtLocation(declaration);
|
|
549
552
|
for (const prop of type.getProperties()) {
|
|
550
|
-
const reflection = rc.createDeclarationReflection(
|
|
553
|
+
const reflection = rc.createDeclarationReflection(ReflectionKind.EnumMember, prop, void 0);
|
|
551
554
|
const propType = context.checker.getTypeOfSymbolAtLocation(prop, declaration);
|
|
552
|
-
reflection.type = context.converter.convertType(
|
|
555
|
+
reflection.type = context.converter.convertType(rc.withScope(reflection), propType);
|
|
553
556
|
rc.finalizeDeclarationReflection(reflection);
|
|
554
557
|
}
|
|
555
558
|
// Skip converting the type alias, if there is one
|
|
556
|
-
return
|
|
559
|
+
return ts.SymbolFlags.TypeAlias;
|
|
557
560
|
}
|
|
558
561
|
function convertVariableAsNamespace(context, symbol, exportSymbol) {
|
|
559
|
-
const reflection = context.createDeclarationReflection(
|
|
562
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Namespace, symbol, exportSymbol);
|
|
560
563
|
context.finalizeDeclarationReflection(reflection);
|
|
561
564
|
const rc = context.withScope(reflection);
|
|
562
565
|
const type = context.checker.getTypeOfSymbol(symbol);
|
|
563
566
|
convertSymbols(rc, type.getProperties());
|
|
564
|
-
return
|
|
567
|
+
return ts.SymbolFlags.Property;
|
|
565
568
|
}
|
|
566
569
|
function convertVariableAsFunction(context, symbol, exportSymbol) {
|
|
567
570
|
const declaration = symbol
|
|
568
571
|
.getDeclarations()
|
|
569
|
-
?.find(
|
|
572
|
+
?.find(ts.isVariableDeclaration);
|
|
570
573
|
const accessDeclaration = declaration ?? symbol.valueDeclaration;
|
|
571
574
|
const type = accessDeclaration
|
|
572
575
|
? context.checker.getTypeOfSymbolAtLocation(symbol, accessDeclaration)
|
|
573
576
|
: context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
574
|
-
const reflection = context.createDeclarationReflection(context.scope.kindOf(
|
|
575
|
-
?
|
|
576
|
-
:
|
|
577
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.MethodContainer)
|
|
578
|
+
? ReflectionKind.Method
|
|
579
|
+
: ReflectionKind.Function, symbol, exportSymbol);
|
|
577
580
|
setModifiers(symbol, accessDeclaration, reflection);
|
|
578
581
|
context.finalizeDeclarationReflection(reflection);
|
|
579
582
|
const reflectionContext = context.withScope(reflection);
|
|
580
583
|
reflection.signatures ??= [];
|
|
581
584
|
for (const signature of type.getCallSignatures()) {
|
|
582
|
-
|
|
585
|
+
createSignature(reflectionContext, ReflectionKind.CallSignature, signature, symbol);
|
|
583
586
|
}
|
|
584
587
|
return (convertFunctionProperties(context.withScope(reflection), symbol, type) |
|
|
585
|
-
|
|
588
|
+
ts.SymbolFlags.Property);
|
|
586
589
|
}
|
|
587
590
|
function convertFunctionProperties(context, symbol, type) {
|
|
588
591
|
// #2436/#2461: Functions created with Object.assign on a function likely have properties
|
|
@@ -592,17 +595,17 @@ function convertFunctionProperties(context, symbol, type) {
|
|
|
592
595
|
// rather than creating a separate namespace.
|
|
593
596
|
// In the expando case, we'll have both namespace flags.
|
|
594
597
|
// In the Object.assign case, we'll have no namespace flags.
|
|
595
|
-
const nsFlags =
|
|
598
|
+
const nsFlags = ts.SymbolFlags.ValueModule | ts.SymbolFlags.NamespaceModule;
|
|
596
599
|
if (type.getProperties().length &&
|
|
597
|
-
(
|
|
598
|
-
!
|
|
600
|
+
(hasAllFlags(symbol.flags, nsFlags) ||
|
|
601
|
+
!hasAnyFlag(symbol.flags, nsFlags))) {
|
|
599
602
|
convertSymbols(context, type.getProperties());
|
|
600
|
-
return
|
|
603
|
+
return ts.SymbolFlags.NamespaceModule;
|
|
601
604
|
}
|
|
602
|
-
return
|
|
605
|
+
return ts.SymbolFlags.None;
|
|
603
606
|
}
|
|
604
607
|
function convertSymbolAsClass(context, symbol, exportSymbol) {
|
|
605
|
-
const reflection = context.createDeclarationReflection(
|
|
608
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Class, symbol, exportSymbol);
|
|
606
609
|
const rc = context.withScope(reflection);
|
|
607
610
|
context.finalizeDeclarationReflection(reflection);
|
|
608
611
|
if (!symbol.valueDeclaration) {
|
|
@@ -615,12 +618,12 @@ function convertSymbolAsClass(context, symbol, exportSymbol) {
|
|
|
615
618
|
// Prototype is implicitly this class, don't document it.
|
|
616
619
|
type.getProperties().filter((prop) => prop.name !== "prototype"));
|
|
617
620
|
for (const sig of type.getCallSignatures()) {
|
|
618
|
-
|
|
621
|
+
createSignature(rc, ReflectionKind.CallSignature, sig, undefined);
|
|
619
622
|
}
|
|
620
623
|
rc.shouldBeStatic = false;
|
|
621
624
|
const ctors = type.getConstructSignatures();
|
|
622
625
|
if (ctors.length) {
|
|
623
|
-
const constructMember = rc.createDeclarationReflection(
|
|
626
|
+
const constructMember = rc.createDeclarationReflection(ReflectionKind.Constructor, ctors[0]?.declaration?.symbol, void 0, "constructor");
|
|
624
627
|
// Modifiers are the same for all constructors
|
|
625
628
|
if (ctors.length && ctors[0].declaration) {
|
|
626
629
|
setModifiers(symbol, ctors[0].declaration, constructMember);
|
|
@@ -628,41 +631,41 @@ function convertSymbolAsClass(context, symbol, exportSymbol) {
|
|
|
628
631
|
context.finalizeDeclarationReflection(constructMember);
|
|
629
632
|
const constructContext = rc.withScope(constructMember);
|
|
630
633
|
for (const sig of ctors) {
|
|
631
|
-
|
|
634
|
+
createConstructSignatureWithType(constructContext, sig, reflection);
|
|
632
635
|
}
|
|
633
636
|
const instType = ctors[0].getReturnType();
|
|
634
637
|
convertSymbols(rc, instType.getProperties());
|
|
635
638
|
for (const sig of instType.getCallSignatures()) {
|
|
636
|
-
|
|
639
|
+
createSignature(rc, ReflectionKind.CallSignature, sig, undefined);
|
|
637
640
|
}
|
|
638
641
|
}
|
|
639
642
|
else {
|
|
640
643
|
context.logger.warn(context.i18n.converting_0_as_class_without_construct_signatures(reflection.getFriendlyFullName()), symbol.valueDeclaration);
|
|
641
644
|
}
|
|
642
|
-
return (
|
|
643
|
-
|
|
644
|
-
|
|
645
|
+
return (ts.SymbolFlags.TypeAlias |
|
|
646
|
+
ts.SymbolFlags.Interface |
|
|
647
|
+
ts.SymbolFlags.Namespace);
|
|
645
648
|
}
|
|
646
649
|
function convertAccessor(context, symbol, exportSymbol) {
|
|
647
|
-
const reflection = context.createDeclarationReflection(
|
|
650
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Accessor, symbol, exportSymbol);
|
|
648
651
|
const rc = context.withScope(reflection);
|
|
649
652
|
const declaration = symbol.getDeclarations()?.[0];
|
|
650
653
|
if (declaration) {
|
|
651
654
|
setModifiers(symbol, declaration, reflection);
|
|
652
655
|
}
|
|
653
656
|
context.finalizeDeclarationReflection(reflection);
|
|
654
|
-
const getDeclaration = symbol.getDeclarations()?.find(
|
|
657
|
+
const getDeclaration = symbol.getDeclarations()?.find(ts.isGetAccessor);
|
|
655
658
|
if (getDeclaration) {
|
|
656
659
|
const signature = context.checker.getSignatureFromDeclaration(getDeclaration);
|
|
657
660
|
if (signature) {
|
|
658
|
-
|
|
661
|
+
createSignature(rc, ReflectionKind.GetSignature, signature, symbol, getDeclaration);
|
|
659
662
|
}
|
|
660
663
|
}
|
|
661
|
-
const setDeclaration = symbol.getDeclarations()?.find(
|
|
664
|
+
const setDeclaration = symbol.getDeclarations()?.find(ts.isSetAccessor);
|
|
662
665
|
if (setDeclaration) {
|
|
663
666
|
const signature = context.checker.getSignatureFromDeclaration(setDeclaration);
|
|
664
667
|
if (signature) {
|
|
665
|
-
|
|
668
|
+
createSignature(rc, ReflectionKind.SetSignature, signature, symbol, setDeclaration);
|
|
666
669
|
}
|
|
667
670
|
}
|
|
668
671
|
}
|
|
@@ -673,41 +676,45 @@ function isInherited(context, symbol) {
|
|
|
673
676
|
if (!parentSymbol)
|
|
674
677
|
return false;
|
|
675
678
|
const parents = parentSymbol.declarations?.slice() || [];
|
|
676
|
-
const constructorDecls = parents.flatMap((parent) =>
|
|
677
|
-
? parent.members.filter(
|
|
679
|
+
const constructorDecls = parents.flatMap((parent) => ts.isClassDeclaration(parent)
|
|
680
|
+
? parent.members.filter(ts.isConstructorDeclaration)
|
|
678
681
|
: []);
|
|
679
682
|
parents.push(...constructorDecls);
|
|
680
683
|
return (parents.some((d) => symbol.getDeclarations()?.some((d2) => d2.parent === d)) === false);
|
|
681
684
|
}
|
|
682
685
|
function setModifiers(symbol, declaration, reflection) {
|
|
686
|
+
setSymbolModifiers(symbol, reflection);
|
|
683
687
|
if (!declaration) {
|
|
684
688
|
return;
|
|
685
689
|
}
|
|
686
|
-
const modifiers =
|
|
687
|
-
if (
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
if (
|
|
691
|
-
reflection.setFlag(
|
|
690
|
+
const modifiers = ts.getCombinedModifierFlags(declaration);
|
|
691
|
+
if (ts.isMethodDeclaration(declaration) ||
|
|
692
|
+
ts.isPropertyDeclaration(declaration) ||
|
|
693
|
+
ts.isAccessor(declaration)) {
|
|
694
|
+
if (ts.isPrivateIdentifier(declaration.name)) {
|
|
695
|
+
reflection.setFlag(ReflectionFlag.Private);
|
|
692
696
|
}
|
|
693
697
|
}
|
|
694
|
-
if (
|
|
695
|
-
reflection.setFlag(
|
|
698
|
+
if (hasAllFlags(modifiers, ts.ModifierFlags.Private)) {
|
|
699
|
+
reflection.setFlag(ReflectionFlag.Private);
|
|
696
700
|
}
|
|
697
|
-
if (
|
|
698
|
-
reflection.setFlag(
|
|
701
|
+
if (hasAllFlags(modifiers, ts.ModifierFlags.Protected)) {
|
|
702
|
+
reflection.setFlag(ReflectionFlag.Protected);
|
|
699
703
|
}
|
|
700
|
-
if (
|
|
701
|
-
reflection.setFlag(
|
|
704
|
+
if (hasAllFlags(modifiers, ts.ModifierFlags.Public)) {
|
|
705
|
+
reflection.setFlag(ReflectionFlag.Public);
|
|
702
706
|
}
|
|
703
|
-
reflection.setFlag(
|
|
704
|
-
reflection.setFlag(
|
|
705
|
-
|
|
706
|
-
reflection.setFlag(
|
|
707
|
-
if (reflection.kindOf(
|
|
708
|
-
|
|
709
|
-
reflection.setFlag(
|
|
707
|
+
reflection.setFlag(ReflectionFlag.Optional, hasAllFlags(symbol.flags, ts.SymbolFlags.Optional));
|
|
708
|
+
reflection.setFlag(ReflectionFlag.Readonly, hasAllFlags(ts.getCheckFlags(symbol), ts.CheckFlags.Readonly) ||
|
|
709
|
+
hasAllFlags(modifiers, ts.ModifierFlags.Readonly));
|
|
710
|
+
reflection.setFlag(ReflectionFlag.Abstract, hasAllFlags(modifiers, ts.ModifierFlags.Abstract));
|
|
711
|
+
if (reflection.kindOf(ReflectionKind.Variable) &&
|
|
712
|
+
hasAllFlags(symbol.flags, ts.SymbolFlags.BlockScopedVariable)) {
|
|
713
|
+
reflection.setFlag(ReflectionFlag.Const, hasAllFlags(declaration.parent.flags, ts.NodeFlags.Const));
|
|
710
714
|
}
|
|
711
715
|
// ReflectionFlag.Static happens when constructing the reflection.
|
|
712
716
|
// We don't have sufficient information here to determine if it ought to be static.
|
|
713
717
|
}
|
|
718
|
+
function setSymbolModifiers(symbol, reflection) {
|
|
719
|
+
reflection.setFlag(ReflectionFlag.Optional, hasAllFlags(symbol.flags, ts.SymbolFlags.Optional));
|
|
720
|
+
}
|