@depup/typedoc 0.28.17-depup.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/LICENSE +201 -0
- package/README.md +34 -0
- package/bin/package.json +3 -0
- package/bin/typedoc +24 -0
- package/changes.json +22 -0
- package/dist/browser-locales/de.d.ts +2 -0
- package/dist/browser-locales/de.js +62 -0
- package/dist/browser-locales/en.d.ts +2 -0
- package/dist/browser-locales/en.js +62 -0
- package/dist/browser-locales/ja.d.ts +2 -0
- package/dist/browser-locales/ja.js +62 -0
- package/dist/browser-locales/ko.d.ts +2 -0
- package/dist/browser-locales/ko.js +62 -0
- package/dist/browser-locales/zh.d.ts +2 -0
- package/dist/browser-locales/zh.js +62 -0
- package/dist/browser-utils.d.ts +3 -0
- package/dist/browser-utils.js +3 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +46 -0
- package/dist/lib/application-events.d.ts +5 -0
- package/dist/lib/application-events.js +5 -0
- package/dist/lib/application.d.ts +195 -0
- package/dist/lib/application.js +715 -0
- package/dist/lib/cli.d.ts +1 -0
- package/dist/lib/cli.js +111 -0
- package/dist/lib/converter/comments/blockLexer.d.ts +4 -0
- package/dist/lib/converter/comments/blockLexer.js +391 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.d.ts +3 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.js +218 -0
- package/dist/lib/converter/comments/discovery.d.ts +14 -0
- package/dist/lib/converter/comments/discovery.js +563 -0
- package/dist/lib/converter/comments/index.d.ts +37 -0
- package/dist/lib/converter/comments/index.js +241 -0
- package/dist/lib/converter/comments/lexer.d.ts +17 -0
- package/dist/lib/converter/comments/lexer.js +10 -0
- package/dist/lib/converter/comments/lineLexer.d.ts +3 -0
- package/dist/lib/converter/comments/lineLexer.js +279 -0
- package/dist/lib/converter/comments/linkResolver.d.ts +20 -0
- package/dist/lib/converter/comments/linkResolver.js +186 -0
- package/dist/lib/converter/comments/parser.d.ts +18 -0
- package/dist/lib/converter/comments/parser.js +538 -0
- package/dist/lib/converter/comments/rawLexer.d.ts +8 -0
- package/dist/lib/converter/comments/rawLexer.js +218 -0
- package/dist/lib/converter/comments/tagName.d.ts +8 -0
- package/dist/lib/converter/comments/tagName.js +58 -0
- package/dist/lib/converter/comments/textParser.d.ts +33 -0
- package/dist/lib/converter/comments/textParser.js +372 -0
- package/dist/lib/converter/components.d.ts +4 -0
- package/dist/lib/converter/components.js +3 -0
- package/dist/lib/converter/context.d.ts +101 -0
- package/dist/lib/converter/context.js +311 -0
- package/dist/lib/converter/convert-expression.d.ts +9 -0
- package/dist/lib/converter/convert-expression.js +58 -0
- package/dist/lib/converter/converter-events.d.ts +13 -0
- package/dist/lib/converter/converter-events.js +13 -0
- package/dist/lib/converter/converter.d.ts +238 -0
- package/dist/lib/converter/converter.js +705 -0
- package/dist/lib/converter/factories/index-signature.d.ts +3 -0
- package/dist/lib/converter/factories/index-signature.js +50 -0
- package/dist/lib/converter/factories/signature.d.ts +14 -0
- package/dist/lib/converter/factories/signature.js +353 -0
- package/dist/lib/converter/factories/symbol-id.d.ts +3 -0
- package/dist/lib/converter/factories/symbol-id.js +47 -0
- package/dist/lib/converter/index.d.ts +5 -0
- package/dist/lib/converter/index.js +3 -0
- package/dist/lib/converter/jsdoc.d.ts +4 -0
- package/dist/lib/converter/jsdoc.js +135 -0
- package/dist/lib/converter/plugins/CategoryPlugin.d.ts +48 -0
- package/dist/lib/converter/plugins/CategoryPlugin.js +278 -0
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +128 -0
- package/dist/lib/converter/plugins/CommentPlugin.js +770 -0
- package/dist/lib/converter/plugins/GroupPlugin.d.ts +48 -0
- package/dist/lib/converter/plugins/GroupPlugin.js +281 -0
- package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +42 -0
- package/dist/lib/converter/plugins/ImplementsPlugin.js +438 -0
- package/dist/lib/converter/plugins/IncludePlugin.d.ts +14 -0
- package/dist/lib/converter/plugins/IncludePlugin.js +254 -0
- package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +32 -0
- package/dist/lib/converter/plugins/InheritDocPlugin.js +220 -0
- package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +13 -0
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +88 -0
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.d.ts +12 -0
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +50 -0
- package/dist/lib/converter/plugins/PackagePlugin.d.ts +31 -0
- package/dist/lib/converter/plugins/PackagePlugin.js +188 -0
- package/dist/lib/converter/plugins/SourcePlugin.d.ts +36 -0
- package/dist/lib/converter/plugins/SourcePlugin.js +215 -0
- package/dist/lib/converter/plugins/TypePlugin.d.ts +16 -0
- package/dist/lib/converter/plugins/TypePlugin.js +108 -0
- package/dist/lib/converter/plugins/index.d.ts +10 -0
- package/dist/lib/converter/plugins/index.js +10 -0
- package/dist/lib/converter/symbols.d.ts +3 -0
- package/dist/lib/converter/symbols.js +861 -0
- package/dist/lib/converter/types.d.ts +10 -0
- package/dist/lib/converter/types.js +833 -0
- package/dist/lib/converter/utils/nodes.d.ts +7 -0
- package/dist/lib/converter/utils/nodes.js +26 -0
- package/dist/lib/converter/utils/reflections.d.ts +2 -0
- package/dist/lib/converter/utils/reflections.js +17 -0
- package/dist/lib/converter/utils/repository.d.ts +96 -0
- package/dist/lib/converter/utils/repository.js +295 -0
- package/dist/lib/converter/utils/symbols.d.ts +2 -0
- package/dist/lib/converter/utils/symbols.js +12 -0
- package/dist/lib/debug/index.d.ts +2 -0
- package/dist/lib/debug/index.js +2 -0
- package/dist/lib/debug/reflectionLifetimes.d.ts +3 -0
- package/dist/lib/debug/reflectionLifetimes.js +27 -0
- package/dist/lib/debug/rendererUrls.d.ts +6 -0
- package/dist/lib/debug/rendererUrls.js +68 -0
- package/dist/lib/internationalization/index.d.ts +7 -0
- package/dist/lib/internationalization/index.js +7 -0
- package/dist/lib/internationalization/internationalization.d.ts +65 -0
- package/dist/lib/internationalization/internationalization.js +64 -0
- package/dist/lib/internationalization/locale-utils.cjs +8 -0
- package/dist/lib/internationalization/locale-utils.d.cts +8 -0
- package/dist/lib/internationalization/locales/de.cjs +401 -0
- package/dist/lib/internationalization/locales/de.d.cts +368 -0
- package/dist/lib/internationalization/locales/en.cjs +411 -0
- package/dist/lib/internationalization/locales/en.d.cts +380 -0
- package/dist/lib/internationalization/locales/ja.cjs +320 -0
- package/dist/lib/internationalization/locales/ja.d.cts +307 -0
- package/dist/lib/internationalization/locales/ko.cjs +233 -0
- package/dist/lib/internationalization/locales/ko.d.cts +221 -0
- package/dist/lib/internationalization/locales/zh.cjs +488 -0
- package/dist/lib/internationalization/locales/zh.d.cts +452 -0
- package/dist/lib/internationalization/translatable.d.ts +21 -0
- package/dist/lib/internationalization/translatable.js +8 -0
- package/dist/lib/models/Comment.d.ts +241 -0
- package/dist/lib/models/Comment.js +534 -0
- package/dist/lib/models/ContainerReflection.d.ts +56 -0
- package/dist/lib/models/ContainerReflection.js +159 -0
- package/dist/lib/models/DeclarationReflection.d.ts +149 -0
- package/dist/lib/models/DeclarationReflection.js +287 -0
- package/dist/lib/models/DocumentReflection.d.ts +32 -0
- package/dist/lib/models/DocumentReflection.js +66 -0
- package/dist/lib/models/FileRegistry.d.ts +46 -0
- package/dist/lib/models/FileRegistry.js +133 -0
- package/dist/lib/models/ParameterReflection.d.ts +21 -0
- package/dist/lib/models/ParameterReflection.js +39 -0
- package/dist/lib/models/ProjectReflection.d.ts +112 -0
- package/dist/lib/models/ProjectReflection.js +417 -0
- package/dist/lib/models/ReferenceReflection.d.ts +49 -0
- package/dist/lib/models/ReferenceReflection.js +85 -0
- package/dist/lib/models/Reflection.d.ts +229 -0
- package/dist/lib/models/Reflection.js +495 -0
- package/dist/lib/models/ReflectionCategory.d.ts +31 -0
- package/dist/lib/models/ReflectionCategory.js +56 -0
- package/dist/lib/models/ReflectionGroup.d.ts +38 -0
- package/dist/lib/models/ReflectionGroup.js +72 -0
- package/dist/lib/models/ReflectionSymbolId.d.ts +63 -0
- package/dist/lib/models/ReflectionSymbolId.js +85 -0
- package/dist/lib/models/SignatureReflection.d.ts +50 -0
- package/dist/lib/models/SignatureReflection.js +96 -0
- package/dist/lib/models/SourceReference.d.ts +33 -0
- package/dist/lib/models/SourceReference.js +50 -0
- package/dist/lib/models/TypeParameterReflection.d.ts +30 -0
- package/dist/lib/models/TypeParameterReflection.js +45 -0
- package/dist/lib/models/index.d.ts +19 -0
- package/dist/lib/models/index.js +19 -0
- package/dist/lib/models/kind.d.ts +84 -0
- package/dist/lib/models/kind.js +231 -0
- package/dist/lib/models/types.d.ts +553 -0
- package/dist/lib/models/types.js +1296 -0
- package/dist/lib/models/utils.d.ts +1 -0
- package/dist/lib/models/utils.js +26 -0
- package/dist/lib/models/variant.d.ts +21 -0
- package/dist/lib/models/variant.js +1 -0
- package/dist/lib/output/components.d.ts +53 -0
- package/dist/lib/output/components.js +133 -0
- package/dist/lib/output/events.d.ts +175 -0
- package/dist/lib/output/events.js +195 -0
- package/dist/lib/output/formatter.d.ts +88 -0
- package/dist/lib/output/formatter.js +660 -0
- package/dist/lib/output/index.d.ts +9 -0
- package/dist/lib/output/index.js +7 -0
- package/dist/lib/output/output.d.ts +14 -0
- package/dist/lib/output/output.js +92 -0
- package/dist/lib/output/plugins/AssetsPlugin.d.ts +20 -0
- package/dist/lib/output/plugins/AssetsPlugin.js +160 -0
- package/dist/lib/output/plugins/HierarchyPlugin.d.ts +7 -0
- package/dist/lib/output/plugins/HierarchyPlugin.js +65 -0
- package/dist/lib/output/plugins/IconsPlugin.d.ts +12 -0
- package/dist/lib/output/plugins/IconsPlugin.js +54 -0
- package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +22 -0
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +222 -0
- package/dist/lib/output/plugins/NavigationPlugin.d.ts +7 -0
- package/dist/lib/output/plugins/NavigationPlugin.js +23 -0
- package/dist/lib/output/plugins/SitemapPlugin.d.ts +8 -0
- package/dist/lib/output/plugins/SitemapPlugin.js +82 -0
- package/dist/lib/output/plugins/index.d.ts +7 -0
- package/dist/lib/output/plugins/index.js +7 -0
- package/dist/lib/output/renderer.d.ts +227 -0
- package/dist/lib/output/renderer.js +387 -0
- package/dist/lib/output/router.d.ts +187 -0
- package/dist/lib/output/router.js +520 -0
- package/dist/lib/output/theme.d.ts +22 -0
- package/dist/lib/output/theme.js +17 -0
- package/dist/lib/output/themes/MarkedPlugin.d.ts +62 -0
- package/dist/lib/output/themes/MarkedPlugin.js +461 -0
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +72 -0
- package/dist/lib/output/themes/default/DefaultTheme.js +367 -0
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +105 -0
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +151 -0
- package/dist/lib/output/themes/default/Slugger.d.ts +13 -0
- package/dist/lib/output/themes/default/Slugger.js +60 -0
- package/dist/lib/output/themes/default/layouts/default.d.ts +6 -0
- package/dist/lib/output/themes/default/layouts/default.js +89 -0
- package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/anchor-icon.js +9 -0
- package/dist/lib/output/themes/default/partials/breadcrumb.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/breadcrumb.js +11 -0
- package/dist/lib/output/themes/default/partials/comment.d.ts +8 -0
- package/dist/lib/output/themes/default/partials/comment.js +80 -0
- package/dist/lib/output/themes/default/partials/footer.d.ts +3 -0
- package/dist/lib/output/themes/default/partials/footer.js +37 -0
- package/dist/lib/output/themes/default/partials/header.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/header.js +39 -0
- package/dist/lib/output/themes/default/partials/hierarchy.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/hierarchy.js +32 -0
- package/dist/lib/output/themes/default/partials/icon.d.ts +20 -0
- package/dist/lib/output/themes/default/partials/icon.js +101 -0
- package/dist/lib/output/themes/default/partials/index.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/index.js +24 -0
- package/dist/lib/output/themes/default/partials/member.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.declaration.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.declaration.js +35 -0
- package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.getterSetter.js +12 -0
- package/dist/lib/output/themes/default/partials/member.js +36 -0
- package/dist/lib/output/themes/default/partials/member.signature.body.d.ts +6 -0
- package/dist/lib/output/themes/default/partials/member.signature.body.js +33 -0
- package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/member.signature.title.js +9 -0
- package/dist/lib/output/themes/default/partials/member.signatures.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.signatures.js +9 -0
- package/dist/lib/output/themes/default/partials/member.sources.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.sources.js +55 -0
- package/dist/lib/output/themes/default/partials/members.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/members.js +17 -0
- package/dist/lib/output/themes/default/partials/moduleReflection.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/moduleReflection.js +68 -0
- package/dist/lib/output/themes/default/partials/navigation.d.ts +10 -0
- package/dist/lib/output/themes/default/partials/navigation.js +144 -0
- package/dist/lib/output/themes/default/partials/reflectionPreview.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +26 -0
- package/dist/lib/output/themes/default/partials/toolbar.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/toolbar.js +13 -0
- package/dist/lib/output/themes/default/partials/type.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/type.js +9 -0
- package/dist/lib/output/themes/default/partials/typeAndParent.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/typeAndParent.js +28 -0
- package/dist/lib/output/themes/default/partials/typeDetails.d.ts +8 -0
- package/dist/lib/output/themes/default/partials/typeDetails.js +284 -0
- package/dist/lib/output/themes/default/partials/typeParameters.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/typeParameters.js +26 -0
- package/dist/lib/output/themes/default/templates/document.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/document.js +3 -0
- package/dist/lib/output/themes/default/templates/hierarchy.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/hierarchy.js +31 -0
- package/dist/lib/output/themes/default/templates/index.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/index.js +3 -0
- package/dist/lib/output/themes/default/templates/reflection.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/reflection.js +53 -0
- package/dist/lib/output/themes/lib.d.ts +44 -0
- package/dist/lib/output/themes/lib.js +218 -0
- package/dist/lib/serialization/components.d.ts +22 -0
- package/dist/lib/serialization/components.js +1 -0
- package/dist/lib/serialization/deserializer.d.ts +70 -0
- package/dist/lib/serialization/deserializer.js +235 -0
- package/dist/lib/serialization/events.d.ts +17 -0
- package/dist/lib/serialization/events.js +18 -0
- package/dist/lib/serialization/index.d.ts +5 -0
- package/dist/lib/serialization/index.js +4 -0
- package/dist/lib/serialization/schema.d.ts +283 -0
- package/dist/lib/serialization/schema.js +32 -0
- package/dist/lib/serialization/serializer.d.ts +52 -0
- package/dist/lib/serialization/serializer.js +65 -0
- package/dist/lib/utils/ValidatingFileRegistry.d.ts +12 -0
- package/dist/lib/utils/ValidatingFileRegistry.js +52 -0
- package/dist/lib/utils/component.d.ts +38 -0
- package/dist/lib/utils/component.js +41 -0
- package/dist/lib/utils/compress.d.ts +7 -0
- package/dist/lib/utils/compress.js +13 -0
- package/dist/lib/utils/declaration-maps.d.ts +3 -0
- package/dist/lib/utils/declaration-maps.js +51 -0
- package/dist/lib/utils/entry-point.d.ts +50 -0
- package/dist/lib/utils/entry-point.js +330 -0
- package/dist/lib/utils/fs.d.ts +65 -0
- package/dist/lib/utils/fs.js +372 -0
- package/dist/lib/utils/general.d.ts +4 -0
- package/dist/lib/utils/general.js +25 -0
- package/dist/lib/utils/highlighter.d.ts +9 -0
- package/dist/lib/utils/highlighter.js +150 -0
- 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 +67 -0
- package/dist/lib/utils/html.js +635 -0
- package/dist/lib/utils/index.d.ts +17 -0
- package/dist/lib/utils/index.js +15 -0
- package/dist/lib/utils/loggers.d.ts +10 -0
- package/dist/lib/utils/loggers.js +71 -0
- package/dist/lib/utils/options/declaration.d.ts +514 -0
- package/dist/lib/utils/options/declaration.js +443 -0
- package/dist/lib/utils/options/defaults.d.ts +20 -0
- package/dist/lib/utils/options/defaults.js +104 -0
- package/dist/lib/utils/options/help.d.ts +7 -0
- package/dist/lib/utils/options/help.js +63 -0
- package/dist/lib/utils/options/index.d.ts +6 -0
- package/dist/lib/utils/options/index.js +4 -0
- package/dist/lib/utils/options/options.d.ts +199 -0
- package/dist/lib/utils/options/options.js +273 -0
- package/dist/lib/utils/options/readers/arguments.d.ts +15 -0
- package/dist/lib/utils/options/readers/arguments.js +109 -0
- package/dist/lib/utils/options/readers/index.d.ts +4 -0
- package/dist/lib/utils/options/readers/index.js +4 -0
- package/dist/lib/utils/options/readers/package-json.d.ts +9 -0
- package/dist/lib/utils/options/readers/package-json.js +40 -0
- package/dist/lib/utils/options/readers/tsconfig.d.ts +14 -0
- package/dist/lib/utils/options/readers/tsconfig.js +172 -0
- package/dist/lib/utils/options/readers/typedoc.d.ts +33 -0
- package/dist/lib/utils/options/readers/typedoc.js +136 -0
- package/dist/lib/utils/options/sources/index.d.ts +1 -0
- package/dist/lib/utils/options/sources/index.js +1 -0
- package/dist/lib/utils/options/sources/typedoc.d.ts +2 -0
- package/dist/lib/utils/options/sources/typedoc.js +876 -0
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +6 -0
- package/dist/lib/utils/options/tsdoc-defaults.js +94 -0
- package/dist/lib/utils/package-manifest.d.ts +11 -0
- package/dist/lib/utils/package-manifest.js +84 -0
- package/dist/lib/utils/paths.d.ts +27 -0
- package/dist/lib/utils/paths.js +127 -0
- package/dist/lib/utils/perf.d.ts +6 -0
- package/dist/lib/utils/perf.js +86 -0
- package/dist/lib/utils/plugins.d.ts +3 -0
- package/dist/lib/utils/plugins.js +61 -0
- package/dist/lib/utils/reflections.d.ts +5 -0
- package/dist/lib/utils/reflections.js +64 -0
- package/dist/lib/utils/sort.d.ts +11 -0
- package/dist/lib/utils/sort.js +153 -0
- package/dist/lib/utils/tsconfig.d.ts +5 -0
- package/dist/lib/utils/tsconfig.js +60 -0
- package/dist/lib/utils/tsutils.d.ts +3 -0
- package/dist/lib/utils/tsutils.js +23 -0
- package/dist/lib/utils-common/array.d.ts +57 -0
- package/dist/lib/utils-common/array.js +152 -0
- package/dist/lib/utils-common/declarationReference.d.ts +42 -0
- package/dist/lib/utils-common/declarationReference.js +341 -0
- package/dist/lib/utils-common/enum.d.ts +9 -0
- package/dist/lib/utils-common/enum.js +27 -0
- package/dist/lib/utils-common/events.d.ts +29 -0
- package/dist/lib/utils-common/events.js +49 -0
- package/dist/lib/utils-common/general.d.ts +40 -0
- package/dist/lib/utils-common/general.js +22 -0
- package/dist/lib/utils-common/hooks.d.ts +51 -0
- package/dist/lib/utils-common/hooks.js +90 -0
- package/dist/lib/utils-common/i18n.d.ts +18 -0
- package/dist/lib/utils-common/i18n.js +39 -0
- package/dist/lib/utils-common/index.d.ts +16 -0
- package/dist/lib/utils-common/index.js +17 -0
- package/dist/lib/utils-common/jsx.d.ts +53 -0
- package/dist/lib/utils-common/jsx.elements.d.ts +949 -0
- package/dist/lib/utils-common/jsx.elements.js +3 -0
- package/dist/lib/utils-common/jsx.js +187 -0
- package/dist/lib/utils-common/logger.d.ts +97 -0
- package/dist/lib/utils-common/logger.js +129 -0
- package/dist/lib/utils-common/map.d.ts +23 -0
- package/dist/lib/utils-common/map.js +63 -0
- package/dist/lib/utils-common/minimalSourceFile.d.ts +12 -0
- package/dist/lib/utils-common/minimalSourceFile.js +43 -0
- package/dist/lib/utils-common/path.d.ts +42 -0
- package/dist/lib/utils-common/path.js +130 -0
- package/dist/lib/utils-common/set.d.ts +3 -0
- package/dist/lib/utils-common/set.js +23 -0
- package/dist/lib/utils-common/string.d.ts +11 -0
- package/dist/lib/utils-common/string.js +84 -0
- package/dist/lib/utils-common/validation.d.ts +33 -0
- package/dist/lib/utils-common/validation.js +50 -0
- package/dist/lib/validation/documentation.d.ts +3 -0
- package/dist/lib/validation/documentation.js +91 -0
- package/dist/lib/validation/exports.d.ts +3 -0
- package/dist/lib/validation/exports.js +65 -0
- package/dist/lib/validation/links.d.ts +3 -0
- package/dist/lib/validation/links.js +78 -0
- package/dist/lib/validation/unusedMergeModuleWith.d.ts +3 -0
- package/dist/lib/validation/unusedMergeModuleWith.js +12 -0
- package/package.json +161 -0
- package/static/main.js +58 -0
- package/static/style.css +1633 -0
- package/tsdoc.json +247 -0
- package/typedoc-config.schema.json +941 -0
|
@@ -0,0 +1,861 @@
|
|
|
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, i18n, removeFlag } from "#utils";
|
|
5
|
+
import { convertDefaultValue } from "./convert-expression.js";
|
|
6
|
+
import { convertIndexSignatures } from "./factories/index-signature.js";
|
|
7
|
+
import { convertConstructSignatures, convertTypeParameters, 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";
|
|
11
|
+
import { resolveAliasedSymbol } from "./utils/symbols.js";
|
|
12
|
+
const symbolConverters = {
|
|
13
|
+
[ts.SymbolFlags.RegularEnum]: convertEnum,
|
|
14
|
+
[ts.SymbolFlags.ConstEnum]: convertEnum,
|
|
15
|
+
[ts.SymbolFlags.EnumMember]: convertEnumMember,
|
|
16
|
+
[ts.SymbolFlags.ValueModule]: convertNamespace,
|
|
17
|
+
[ts.SymbolFlags.NamespaceModule]: convertNamespace,
|
|
18
|
+
[ts.SymbolFlags.TypeAlias]: convertTypeAlias,
|
|
19
|
+
[ts.SymbolFlags.Function]: convertFunctionOrMethod,
|
|
20
|
+
[ts.SymbolFlags.Method]: convertFunctionOrMethod,
|
|
21
|
+
[ts.SymbolFlags.Interface]: convertClassOrInterface,
|
|
22
|
+
[ts.SymbolFlags.Property]: convertProperty,
|
|
23
|
+
[ts.SymbolFlags.Class]: convertClassOrInterface,
|
|
24
|
+
[ts.SymbolFlags.Constructor]: convertConstructor,
|
|
25
|
+
[ts.SymbolFlags.Alias]: convertAlias,
|
|
26
|
+
[ts.SymbolFlags.BlockScopedVariable]: convertVariable,
|
|
27
|
+
[ts.SymbolFlags.FunctionScopedVariable]: convertVariable,
|
|
28
|
+
[ts.SymbolFlags.ExportValue]: convertVariable,
|
|
29
|
+
[ts.SymbolFlags.GetAccessor]: convertAccessor,
|
|
30
|
+
[ts.SymbolFlags.SetAccessor]: convertAccessor,
|
|
31
|
+
};
|
|
32
|
+
const allConverterFlags = Object.keys(symbolConverters).reduce((v, k) => v | +k, 0);
|
|
33
|
+
// This is kind of a hack, born of resolving references by symbols instead
|
|
34
|
+
// of by source location.
|
|
35
|
+
const conversionOrder = [
|
|
36
|
+
// Do enums before namespaces so that @hidden on a namespace
|
|
37
|
+
// merged with an enum works properly.
|
|
38
|
+
ts.SymbolFlags.RegularEnum,
|
|
39
|
+
ts.SymbolFlags.ConstEnum,
|
|
40
|
+
ts.SymbolFlags.EnumMember,
|
|
41
|
+
// Before type alias
|
|
42
|
+
ts.SymbolFlags.BlockScopedVariable,
|
|
43
|
+
ts.SymbolFlags.FunctionScopedVariable,
|
|
44
|
+
ts.SymbolFlags.ExportValue,
|
|
45
|
+
ts.SymbolFlags.Function, // Before NamespaceModule
|
|
46
|
+
ts.SymbolFlags.TypeAlias,
|
|
47
|
+
ts.SymbolFlags.Method,
|
|
48
|
+
ts.SymbolFlags.Interface,
|
|
49
|
+
ts.SymbolFlags.Property,
|
|
50
|
+
ts.SymbolFlags.Class,
|
|
51
|
+
ts.SymbolFlags.Constructor,
|
|
52
|
+
ts.SymbolFlags.Alias,
|
|
53
|
+
ts.SymbolFlags.GetAccessor,
|
|
54
|
+
ts.SymbolFlags.SetAccessor,
|
|
55
|
+
ts.SymbolFlags.ValueModule,
|
|
56
|
+
ts.SymbolFlags.NamespaceModule,
|
|
57
|
+
];
|
|
58
|
+
// Sanity check, if this fails a dev messed up.
|
|
59
|
+
for (const key of Object.keys(symbolConverters)) {
|
|
60
|
+
assert(Number.isInteger(Math.log2(+key)), `Symbol converter for key ${ts.SymbolFlags[+key]} does not specify a valid flag value.`);
|
|
61
|
+
assert(conversionOrder.includes(+key), `Symbol converter for key ${ts.SymbolFlags[+key]} is not specified in conversionOrder`);
|
|
62
|
+
}
|
|
63
|
+
assert(conversionOrder.reduce((a, b) => a | b, 0) === allConverterFlags, "conversionOrder contains a symbol flag that converters do not.");
|
|
64
|
+
function _convertSymbolNow(context, symbol, exportSymbol) {
|
|
65
|
+
if (context.shouldIgnore(resolveAliasedSymbol(symbol, context.checker))) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// This check can catch symbols which ought to be documented as references
|
|
69
|
+
// but aren't aliased symbols because `export *` was used.
|
|
70
|
+
const previous = context.getReflectionFromSymbol(symbol);
|
|
71
|
+
if (previous &&
|
|
72
|
+
previous.parent?.kindOf(ReflectionKind.SomeModule | ReflectionKind.Project)) {
|
|
73
|
+
createAlias(previous, context, symbol, exportSymbol);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let flags = removeFlag(symbol.flags, ts.SymbolFlags.Transient |
|
|
77
|
+
ts.SymbolFlags.Assignment |
|
|
78
|
+
ts.SymbolFlags.Optional |
|
|
79
|
+
ts.SymbolFlags.Prototype);
|
|
80
|
+
// Declaration merging - the only type (excluding enum/enum, ns/ns, etc)
|
|
81
|
+
// that TD supports is merging a class and interface. All others are
|
|
82
|
+
// represented as multiple reflections
|
|
83
|
+
if (hasAllFlags(symbol.flags, ts.SymbolFlags.Class)) {
|
|
84
|
+
flags = removeFlag(flags, ts.SymbolFlags.Interface | ts.SymbolFlags.Function);
|
|
85
|
+
}
|
|
86
|
+
// Kind of declaration merging... we treat this as a property with get/set signatures.
|
|
87
|
+
if (hasAllFlags(symbol.flags, ts.SymbolFlags.GetAccessor)) {
|
|
88
|
+
flags = removeFlag(flags, ts.SymbolFlags.SetAccessor);
|
|
89
|
+
}
|
|
90
|
+
if (hasAllFlags(symbol.flags, ts.SymbolFlags.NamespaceModule)) {
|
|
91
|
+
// This might be here if a namespace is declared several times.
|
|
92
|
+
// Or if it's a namespace-like thing defined on a function
|
|
93
|
+
// In the function case, it's important to remove ValueModule so that
|
|
94
|
+
// if we convert the children as properties of the function rather than as
|
|
95
|
+
// a separate namespace, we skip creating the namespace.
|
|
96
|
+
flags = removeFlag(flags, ts.SymbolFlags.ValueModule);
|
|
97
|
+
}
|
|
98
|
+
if (hasAnyFlag(symbol.flags, ts.SymbolFlags.Method |
|
|
99
|
+
ts.SymbolFlags.Interface |
|
|
100
|
+
ts.SymbolFlags.Class |
|
|
101
|
+
ts.SymbolFlags.Variable)) {
|
|
102
|
+
// This happens when someone declares an object with methods:
|
|
103
|
+
// { methodProperty() {} }
|
|
104
|
+
flags = removeFlag(flags, ts.SymbolFlags.Property);
|
|
105
|
+
}
|
|
106
|
+
for (const flag of getEnumFlags(flags & ~allConverterFlags)) {
|
|
107
|
+
context.logger.verbose(`Missing converter for symbol: ${symbol.name} with flag ${ts.SymbolFlags[flag]}`);
|
|
108
|
+
}
|
|
109
|
+
const selectedConverters = conversionOrder.filter(flag => flag & flags);
|
|
110
|
+
let skip = 0;
|
|
111
|
+
for (const flag of selectedConverters) {
|
|
112
|
+
if (skip & flag)
|
|
113
|
+
continue;
|
|
114
|
+
skip |= symbolConverters[flag]?.(context, symbol, exportSymbol) || 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function convertSymbol(context, symbol, exportSymbol) {
|
|
118
|
+
// #1795, defer conversion of symbols named `default` so that if a function
|
|
119
|
+
// is default exported and also exported with a name, the name takes precedence
|
|
120
|
+
if ((exportSymbol?.name ?? symbol.name) === "default" &&
|
|
121
|
+
context.scope.kindOf(ReflectionKind.ExportContainer)) {
|
|
122
|
+
context.converter.deferConversion(() => {
|
|
123
|
+
_convertSymbolNow(context, symbol, exportSymbol);
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
_convertSymbolNow(context, symbol, exportSymbol);
|
|
128
|
+
}
|
|
129
|
+
function convertSymbols(context, symbols) {
|
|
130
|
+
for (const symbol of symbols) {
|
|
131
|
+
convertSymbol(context, symbol);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function convertEnum(context, symbol, exportSymbol) {
|
|
135
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Enum, symbol, exportSymbol);
|
|
136
|
+
if (symbol.flags & ts.SymbolFlags.ConstEnum) {
|
|
137
|
+
reflection.setFlag(ReflectionFlag.Const);
|
|
138
|
+
}
|
|
139
|
+
context.finalizeDeclarationReflection(reflection);
|
|
140
|
+
convertSymbols(context.withScope(reflection), context.checker
|
|
141
|
+
.getExportsOfModule(symbol)
|
|
142
|
+
.filter((s) => s.flags & ts.SymbolFlags.EnumMember));
|
|
143
|
+
}
|
|
144
|
+
function convertEnumMember(context, symbol, exportSymbol) {
|
|
145
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.EnumMember, symbol, exportSymbol);
|
|
146
|
+
const defaultValue = context.checker.getConstantValue(symbol.getDeclarations()[0]);
|
|
147
|
+
if (defaultValue !== undefined) {
|
|
148
|
+
reflection.type = new LiteralType(defaultValue);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// We know this has to be a number, because computed values aren't allowed
|
|
152
|
+
// in string enums, so otherwise we would have to have the constant value
|
|
153
|
+
reflection.type = new IntrinsicType("number");
|
|
154
|
+
}
|
|
155
|
+
context.finalizeDeclarationReflection(reflection);
|
|
156
|
+
}
|
|
157
|
+
function convertNamespace(context, symbol, exportSymbol) {
|
|
158
|
+
let exportFlags = ts.SymbolFlags.ModuleMember;
|
|
159
|
+
// This can happen in JS land where "class" functions get tagged as a namespace too
|
|
160
|
+
if (symbol
|
|
161
|
+
.getDeclarations()
|
|
162
|
+
?.some((d) => ts.isModuleDeclaration(d) || ts.isSourceFile(d)) !==
|
|
163
|
+
true) {
|
|
164
|
+
exportFlags = ts.SymbolFlags.ClassMember;
|
|
165
|
+
if (hasAnyFlag(symbol.flags, ts.SymbolFlags.Class)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (symbol.declarations?.some(ts.isFunctionDeclaration)) {
|
|
170
|
+
exportFlags |= ts.SymbolFlags.PropertyOrAccessor;
|
|
171
|
+
}
|
|
172
|
+
// #2364, @namespace on a variable might be merged with a namespace containing types.
|
|
173
|
+
const existingReflection = context.getReflectionFromSymbol(exportSymbol || symbol);
|
|
174
|
+
let reflection;
|
|
175
|
+
if (existingReflection?.kind === ReflectionKind.Namespace) {
|
|
176
|
+
reflection = existingReflection;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
let kind = ReflectionKind.Namespace;
|
|
180
|
+
let nameOverride;
|
|
181
|
+
// #2778 - always treat declare module "foo" as a module, not a namespace
|
|
182
|
+
const declareModule = symbol.declarations?.find((mod) => ts.isModuleDeclaration(mod) && ts.isStringLiteral(mod.name));
|
|
183
|
+
if (declareModule) {
|
|
184
|
+
kind = ReflectionKind.Module;
|
|
185
|
+
nameOverride = declareModule.name.text;
|
|
186
|
+
}
|
|
187
|
+
reflection = context.createDeclarationReflection(kind, symbol, exportSymbol, nameOverride);
|
|
188
|
+
context.finalizeDeclarationReflection(reflection);
|
|
189
|
+
}
|
|
190
|
+
convertSymbols(context.withScope(reflection), context.checker
|
|
191
|
+
.getExportsOfModule(symbol)
|
|
192
|
+
.filter((s) => s.flags & exportFlags));
|
|
193
|
+
}
|
|
194
|
+
function convertTypeAlias(context, symbol, exportSymbol) {
|
|
195
|
+
const declaration = symbol
|
|
196
|
+
.getDeclarations()
|
|
197
|
+
?.find((d) => ts.isTypeAliasDeclaration(d) ||
|
|
198
|
+
ts.isJSDocTypedefTag(d) ||
|
|
199
|
+
ts.isJSDocCallbackTag(d) ||
|
|
200
|
+
ts.isJSDocEnumTag(d));
|
|
201
|
+
assert(declaration);
|
|
202
|
+
if (ts.isTypeAliasDeclaration(declaration)) {
|
|
203
|
+
if (context
|
|
204
|
+
.getComment(symbol, ReflectionKind.TypeAlias)
|
|
205
|
+
?.hasModifier("@interface")) {
|
|
206
|
+
return convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration);
|
|
207
|
+
}
|
|
208
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.TypeAlias, symbol, exportSymbol);
|
|
209
|
+
context.finalizeDeclarationReflection(reflection);
|
|
210
|
+
if (reflection.comment?.hasModifier("@useDeclaredType")) {
|
|
211
|
+
reflection.comment.removeModifier("@useDeclaredType");
|
|
212
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getDeclaredTypeOfSymbol(symbol));
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), declaration.type);
|
|
216
|
+
}
|
|
217
|
+
if (reflection.type.type === "union") {
|
|
218
|
+
attachUnionComments(context, declaration, reflection.type);
|
|
219
|
+
}
|
|
220
|
+
else if (reflection.type.type === "reflection" && reflection.type.declaration.children) {
|
|
221
|
+
// #2817 lift properties of object literal types up to the reflection level.
|
|
222
|
+
const typeDecl = reflection.type.declaration;
|
|
223
|
+
reflection.project.mergeReflections(typeDecl, reflection);
|
|
224
|
+
delete reflection.type;
|
|
225
|
+
// When created any signatures will be created with __type as their
|
|
226
|
+
// name, rename them so that they have the alias's name as their name
|
|
227
|
+
for (const sig of reflection.signatures || []) {
|
|
228
|
+
sig.name = reflection.name;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
reflection.typeParameters = declaration.typeParameters?.map((param) => createTypeParamReflection(param, context.withScope(reflection)));
|
|
232
|
+
}
|
|
233
|
+
else if (ts.isJSDocTypedefTag(declaration) ||
|
|
234
|
+
ts.isJSDocEnumTag(declaration)) {
|
|
235
|
+
convertJsDocAlias(context, symbol, declaration, exportSymbol);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
convertJsDocCallback(context, symbol, declaration, exportSymbol);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function convertTypeAliasFromValueDeclaration(context, symbol, exportSymbol, valueKind) {
|
|
242
|
+
const comment = context.getComment(symbol, valueKind);
|
|
243
|
+
const reflection = new DeclarationReflection(exportSymbol?.name || symbol.name, ReflectionKind.TypeAlias, context.scope);
|
|
244
|
+
reflection.comment = comment;
|
|
245
|
+
context.postReflectionCreation(reflection, symbol, exportSymbol);
|
|
246
|
+
context.finalizeDeclarationReflection(reflection);
|
|
247
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getTypeOfSymbol(symbol));
|
|
248
|
+
if (reflection.type.type === "reflection" && reflection.type.declaration.children) {
|
|
249
|
+
// #2817 lift properties of object literal types up to the reflection level.
|
|
250
|
+
const typeDecl = reflection.type.declaration;
|
|
251
|
+
reflection.project.mergeReflections(typeDecl, reflection);
|
|
252
|
+
delete reflection.type;
|
|
253
|
+
// When created any signatures will be created with __type as their
|
|
254
|
+
// name, rename them so that they have the alias's name as their name
|
|
255
|
+
for (const sig of reflection.signatures || []) {
|
|
256
|
+
sig.name = reflection.name;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function attachUnionComments(context, declaration, union) {
|
|
261
|
+
const list = declaration.type.getChildAt(0);
|
|
262
|
+
if (list.kind !== ts.SyntaxKind.SyntaxList)
|
|
263
|
+
return;
|
|
264
|
+
let unionIndex = 0;
|
|
265
|
+
for (const child of list.getChildren()) {
|
|
266
|
+
const comment = context.getNodeComment(child, false);
|
|
267
|
+
if (comment?.modifierTags.size || comment?.blockTags.length) {
|
|
268
|
+
context.logger.warn(i18n.comment_for_0_should_not_contain_block_or_modifier_tags(`${context.scope.getFriendlyFullName()}.${unionIndex}`), child);
|
|
269
|
+
}
|
|
270
|
+
if (comment) {
|
|
271
|
+
union.elementSummaries ||= Array.from({ length: union.types.length }, () => []);
|
|
272
|
+
union.elementSummaries[unionIndex] = comment.summary;
|
|
273
|
+
}
|
|
274
|
+
if (child.kind !== ts.SyntaxKind.BarToken) {
|
|
275
|
+
++unionIndex;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function convertTypeAliasAsInterface(context, symbol, exportSymbol, declaration) {
|
|
280
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Interface, symbol, exportSymbol);
|
|
281
|
+
context.finalizeDeclarationReflection(reflection);
|
|
282
|
+
const rc = context.withScope(reflection);
|
|
283
|
+
const type = context.checker.getTypeAtLocation(declaration);
|
|
284
|
+
if (type.getFlags() & ts.TypeFlags.Union) {
|
|
285
|
+
context.logger.warn(i18n.converting_union_as_interface(), declaration);
|
|
286
|
+
}
|
|
287
|
+
// Interfaces have properties
|
|
288
|
+
convertSymbols(rc, type.getProperties());
|
|
289
|
+
// And type arguments
|
|
290
|
+
if (declaration.typeParameters) {
|
|
291
|
+
reflection.typeParameters = declaration.typeParameters.map((param) => {
|
|
292
|
+
const declaration = param.symbol?.declarations?.[0];
|
|
293
|
+
assert(declaration && ts.isTypeParameterDeclaration(declaration));
|
|
294
|
+
return createTypeParamReflection(declaration, rc);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// And maybe call signatures
|
|
298
|
+
context.checker
|
|
299
|
+
.getSignaturesOfType(type, ts.SignatureKind.Call)
|
|
300
|
+
.forEach((sig) => createSignature(rc, ReflectionKind.CallSignature, sig, symbol));
|
|
301
|
+
// And maybe constructor signatures
|
|
302
|
+
convertConstructSignatures(rc, symbol);
|
|
303
|
+
// And finally, index signatures
|
|
304
|
+
convertIndexSignatures(rc, type);
|
|
305
|
+
}
|
|
306
|
+
function convertFunctionOrMethod(context, symbol, exportSymbol) {
|
|
307
|
+
if (isTypeOnlyExport(exportSymbol)) {
|
|
308
|
+
return convertTypeAliasFromValueDeclaration(context, symbol, exportSymbol, ReflectionKind.Function);
|
|
309
|
+
}
|
|
310
|
+
// Can't just check method flag because this might be called for properties as well
|
|
311
|
+
// This will *NOT* be called for variables that look like functions, they need a special case.
|
|
312
|
+
const isMethod = !!(symbol.flags &
|
|
313
|
+
(ts.SymbolFlags.Property | ts.SymbolFlags.Method));
|
|
314
|
+
if (!isMethod) {
|
|
315
|
+
const comment = context.getComment(symbol, ReflectionKind.Function);
|
|
316
|
+
if (comment?.hasModifier("@class")) {
|
|
317
|
+
return convertSymbolAsClass(context, symbol, exportSymbol);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const declarations = symbol.getDeclarations()?.filter(ts.isFunctionLike) ?? [];
|
|
321
|
+
// Don't do anything if we inherited this method and it is private.
|
|
322
|
+
if (isMethod &&
|
|
323
|
+
isInherited(context, symbol) &&
|
|
324
|
+
declarations.length > 0 &&
|
|
325
|
+
hasAllFlags(ts.getCombinedModifierFlags(declarations[0]), ts.ModifierFlags.Private)) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const locationDeclaration = symbol.parent
|
|
329
|
+
?.getDeclarations()
|
|
330
|
+
?.find((d) => ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) ??
|
|
331
|
+
symbol.parent?.getDeclarations()?.[0]?.getSourceFile() ??
|
|
332
|
+
symbol.getDeclarations()?.[0]?.getSourceFile();
|
|
333
|
+
assert(locationDeclaration, "Missing declaration context");
|
|
334
|
+
const type = context.checker.getTypeOfSymbolAtLocation(symbol, locationDeclaration);
|
|
335
|
+
// Need to get the non nullable type because interface methods might be declared
|
|
336
|
+
// with a question token. See GH1490.
|
|
337
|
+
const signatures = type.getNonNullableType().getCallSignatures();
|
|
338
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.MethodContainer)
|
|
339
|
+
? ReflectionKind.Method
|
|
340
|
+
: ReflectionKind.Function, symbol, exportSymbol, void 0);
|
|
341
|
+
if (symbol.declarations?.length && isMethod) {
|
|
342
|
+
// All method signatures must have the same modifier flags.
|
|
343
|
+
setModifiers(symbol, symbol.declarations[0], reflection);
|
|
344
|
+
}
|
|
345
|
+
context.finalizeDeclarationReflection(reflection);
|
|
346
|
+
const scope = context.withScope(reflection);
|
|
347
|
+
for (const sig of signatures) {
|
|
348
|
+
createSignature(scope, ReflectionKind.CallSignature, sig, symbol);
|
|
349
|
+
}
|
|
350
|
+
return convertFunctionProperties(scope, symbol, type);
|
|
351
|
+
}
|
|
352
|
+
// getDeclaredTypeOfSymbol gets the INSTANCE type
|
|
353
|
+
// getTypeOfSymbolAtLocation gets the STATIC type
|
|
354
|
+
function convertClassOrInterface(context, symbol, exportSymbol) {
|
|
355
|
+
const reflection = context.createDeclarationReflection((ts.SymbolFlags.Class & symbol.flags) && !isTypeOnlyExport(exportSymbol)
|
|
356
|
+
? ReflectionKind.Class
|
|
357
|
+
: ReflectionKind.Interface, symbol, exportSymbol, void 0);
|
|
358
|
+
const classDeclaration = symbol
|
|
359
|
+
.getDeclarations()
|
|
360
|
+
?.find((d) => ts.isClassDeclaration(d) || ts.isFunctionDeclaration(d));
|
|
361
|
+
if (classDeclaration)
|
|
362
|
+
setModifiers(symbol, classDeclaration, reflection);
|
|
363
|
+
const reflectionContext = context.withScope(reflection);
|
|
364
|
+
reflectionContext.convertingClassOrInterface = true;
|
|
365
|
+
const instanceType = context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
366
|
+
assert(instanceType.isClassOrInterface());
|
|
367
|
+
// We might do some inheritance - do this first so that it's set when converting properties
|
|
368
|
+
const declarations = symbol
|
|
369
|
+
.getDeclarations()
|
|
370
|
+
?.filter((d) => ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) ?? [];
|
|
371
|
+
const extendedTypes = getHeritageTypes(declarations, ts.SyntaxKind.ExtendsKeyword).map((t) => context.converter.convertType(reflectionContext, t));
|
|
372
|
+
if (extendedTypes.length) {
|
|
373
|
+
reflection.extendedTypes = extendedTypes;
|
|
374
|
+
}
|
|
375
|
+
const implementedTypes = getHeritageTypes(declarations, ts.SyntaxKind.ImplementsKeyword).map((t) => context.converter.convertType(reflectionContext, t));
|
|
376
|
+
if (implementedTypes.length) {
|
|
377
|
+
reflection.implementedTypes = implementedTypes;
|
|
378
|
+
}
|
|
379
|
+
context.finalizeDeclarationReflection(reflection);
|
|
380
|
+
// Convert type parameters early so that we get access them when converting the constructors if any
|
|
381
|
+
if (instanceType.typeParameters) {
|
|
382
|
+
reflection.typeParameters = instanceType.typeParameters.map((param) => {
|
|
383
|
+
const declaration = param.symbol.declarations?.[0];
|
|
384
|
+
assert(declaration && ts.isTypeParameterDeclaration(declaration));
|
|
385
|
+
return createTypeParamReflection(declaration, reflectionContext);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (classDeclaration && reflection.kind === ReflectionKind.Class) {
|
|
389
|
+
// Classes can have static props
|
|
390
|
+
const staticType = context.checker.getTypeOfSymbolAtLocation(symbol, classDeclaration);
|
|
391
|
+
reflectionContext.shouldBeStatic = true;
|
|
392
|
+
for (const prop of context.checker.getPropertiesOfType(staticType)) {
|
|
393
|
+
// Don't convert namespace members, or the prototype here.
|
|
394
|
+
if (prop.flags &
|
|
395
|
+
(ts.SymbolFlags.ModuleMember | ts.SymbolFlags.Prototype)) {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
convertSymbol(reflectionContext, prop);
|
|
399
|
+
}
|
|
400
|
+
reflectionContext.shouldBeStatic = false;
|
|
401
|
+
const ctors = staticType.getConstructSignatures();
|
|
402
|
+
const constructMember = reflectionContext.createDeclarationReflection(ReflectionKind.Constructor, ctors[0]?.declaration?.symbol, void 0, "constructor");
|
|
403
|
+
// Modifiers are the same for all constructors
|
|
404
|
+
if (ctors.length && ctors[0].declaration) {
|
|
405
|
+
setModifiers(symbol, ctors[0].declaration, constructMember);
|
|
406
|
+
}
|
|
407
|
+
context.finalizeDeclarationReflection(constructMember);
|
|
408
|
+
const constructContext = reflectionContext.withScope(constructMember);
|
|
409
|
+
ctors.forEach((sig) => {
|
|
410
|
+
createSignature(constructContext, ReflectionKind.ConstructorSignature, sig, symbol);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
// Classes/interfaces usually just have properties...
|
|
414
|
+
convertSymbols(reflectionContext, context.checker.getPropertiesOfType(instanceType));
|
|
415
|
+
// Interfaces might also have call signatures
|
|
416
|
+
// Classes might too, because of declaration merging
|
|
417
|
+
context.checker
|
|
418
|
+
.getSignaturesOfType(instanceType, ts.SignatureKind.Call)
|
|
419
|
+
.forEach((sig) => createSignature(reflectionContext, ReflectionKind.CallSignature, sig, symbol));
|
|
420
|
+
// We also might have constructor signatures
|
|
421
|
+
// This is potentially a problem with classes having multiple "constructor" members...
|
|
422
|
+
// but nobody has complained yet.
|
|
423
|
+
convertConstructSignatures(reflectionContext, symbol);
|
|
424
|
+
// And finally, index signatures
|
|
425
|
+
convertIndexSignatures(reflectionContext, instanceType);
|
|
426
|
+
// Normally this shouldn't matter, unless someone did something with skipLibCheck on.
|
|
427
|
+
return ts.SymbolFlags.Alias;
|
|
428
|
+
}
|
|
429
|
+
function convertProperty(context, symbol, exportSymbol) {
|
|
430
|
+
// This might happen if we're converting a function-module created with Object.assign
|
|
431
|
+
// or `export default () => {}`
|
|
432
|
+
if (context.scope.kindOf(ReflectionKind.VariableContainer)) {
|
|
433
|
+
return convertVariable(context, symbol, exportSymbol);
|
|
434
|
+
}
|
|
435
|
+
const declarations = symbol.getDeclarations() ?? [];
|
|
436
|
+
// Don't do anything if we inherited this property and it is private.
|
|
437
|
+
if (isInherited(context, symbol) &&
|
|
438
|
+
declarations.length > 0 &&
|
|
439
|
+
hasAllFlags(ts.getCombinedModifierFlags(declarations[0]), ts.ModifierFlags.Private)) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
// Special case: We pretend properties are methods if they look like methods.
|
|
443
|
+
// This happens with mixins / weird inheritance. Don't do this if the type
|
|
444
|
+
// doesn't have call signatures to avoid converting non-functions. This can
|
|
445
|
+
// happen if @class is used and functions are converted to their return type
|
|
446
|
+
// with a mapped type (e.g. with Vue's `computed` properties)
|
|
447
|
+
const type = context.checker.getTypeOfSymbol(symbol);
|
|
448
|
+
if (type.getCallSignatures().length &&
|
|
449
|
+
declarations.length &&
|
|
450
|
+
declarations.every((decl) => ts.isMethodSignature(decl) || ts.isMethodDeclaration(decl))) {
|
|
451
|
+
return convertFunctionOrMethod(context, symbol, exportSymbol);
|
|
452
|
+
}
|
|
453
|
+
if (declarations.length === 1) {
|
|
454
|
+
const declaration = declarations[0];
|
|
455
|
+
// Special case: "arrow methods" should be treated as methods.
|
|
456
|
+
if (ts.isPropertyDeclaration(declaration) &&
|
|
457
|
+
!declaration.type &&
|
|
458
|
+
declaration.initializer &&
|
|
459
|
+
ts.isArrowFunction(declaration.initializer)) {
|
|
460
|
+
return convertArrowAsMethod(context, symbol, declaration.initializer, exportSymbol);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.VariableContainer)
|
|
464
|
+
? ReflectionKind.Variable
|
|
465
|
+
: ReflectionKind.Property, symbol, exportSymbol);
|
|
466
|
+
const declaration = symbol.getDeclarations()?.[0];
|
|
467
|
+
let parameterTypeNode;
|
|
468
|
+
if (declaration &&
|
|
469
|
+
(ts.isPropertyDeclaration(declaration) ||
|
|
470
|
+
ts.isPropertySignature(declaration) ||
|
|
471
|
+
ts.isParameter(declaration) ||
|
|
472
|
+
ts.isPropertyAccessExpression(declaration) ||
|
|
473
|
+
ts.isPropertyAssignment(declaration))) {
|
|
474
|
+
if (!ts.isPropertyAccessExpression(declaration) &&
|
|
475
|
+
!ts.isPropertyAssignment(declaration)) {
|
|
476
|
+
parameterTypeNode = declaration.type;
|
|
477
|
+
}
|
|
478
|
+
setModifiers(symbol, declaration, reflection);
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
setSymbolModifiers(symbol, reflection);
|
|
482
|
+
}
|
|
483
|
+
reflection.defaultValue = declaration && convertDefaultValue(declaration);
|
|
484
|
+
if (context.convertingTypeNode && parameterTypeNode) {
|
|
485
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), parameterTypeNode);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getTypeOfSymbol(symbol), parameterTypeNode);
|
|
489
|
+
}
|
|
490
|
+
if (reflection.flags.isOptional) {
|
|
491
|
+
reflection.type = removeUndefined(reflection.type);
|
|
492
|
+
}
|
|
493
|
+
context.finalizeDeclarationReflection(reflection);
|
|
494
|
+
}
|
|
495
|
+
function convertArrowAsMethod(context, symbol, arrow, exportSymbol) {
|
|
496
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Method, symbol, exportSymbol, void 0);
|
|
497
|
+
setModifiers(symbol, arrow.parent, reflection);
|
|
498
|
+
context.finalizeDeclarationReflection(reflection);
|
|
499
|
+
const rc = context.withScope(reflection);
|
|
500
|
+
const locationDeclaration = symbol.parent
|
|
501
|
+
?.getDeclarations()
|
|
502
|
+
?.find((d) => ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) ??
|
|
503
|
+
symbol.parent?.getDeclarations()?.[0]?.getSourceFile() ??
|
|
504
|
+
symbol.getDeclarations()?.[0]?.getSourceFile();
|
|
505
|
+
assert(locationDeclaration, "Missing declaration context");
|
|
506
|
+
const type = context.checker.getTypeOfSymbolAtLocation(symbol, locationDeclaration);
|
|
507
|
+
const signatures = type.getNonNullableType().getCallSignatures();
|
|
508
|
+
assert(signatures.length, "Missing signatures");
|
|
509
|
+
createSignature(rc, ReflectionKind.CallSignature, signatures[0], symbol, arrow);
|
|
510
|
+
}
|
|
511
|
+
function convertConstructor(context, symbol) {
|
|
512
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Constructor, symbol, void 0, "constructor");
|
|
513
|
+
context.finalizeDeclarationReflection(reflection);
|
|
514
|
+
const reflectionContext = context.withScope(reflection);
|
|
515
|
+
const declarations = symbol.getDeclarations()?.filter(ts.isConstructorDeclaration) ?? [];
|
|
516
|
+
const signatures = declarations.map((decl) => {
|
|
517
|
+
const sig = context.checker.getSignatureFromDeclaration(decl);
|
|
518
|
+
assert(sig);
|
|
519
|
+
return sig;
|
|
520
|
+
});
|
|
521
|
+
for (const sig of signatures) {
|
|
522
|
+
createSignature(reflectionContext, ReflectionKind.ConstructorSignature, sig, symbol);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function convertAlias(context, symbol, exportSymbol) {
|
|
526
|
+
// If this is a namespace marked as a primary export or directly within one
|
|
527
|
+
// marked as a primary export then we should convert it immediately rather than deferring
|
|
528
|
+
if (context.scope.comment?.hasModifier("@primaryExport") ||
|
|
529
|
+
context.getComment(exportSymbol || symbol, ReflectionKind.Namespace)?.hasModifier("@primaryExport")) {
|
|
530
|
+
_convertAlias();
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
// Defer conversion of aliases so that if the original module/namespace
|
|
534
|
+
// containing them is included in the docs, we will point to that namespace
|
|
535
|
+
// rather than pointing that namespace to the first namespace encountered, #2856.
|
|
536
|
+
context.converter.deferConversion(_convertAlias);
|
|
537
|
+
}
|
|
538
|
+
function _convertAlias() {
|
|
539
|
+
const reflection = context.getReflectionFromSymbol(context.resolveAliasedSymbol(symbol));
|
|
540
|
+
if (!reflection ||
|
|
541
|
+
(reflection &&
|
|
542
|
+
!reflection.parent?.kindOf(ReflectionKind.Project | ReflectionKind.SomeModule))) {
|
|
543
|
+
// We don't have this, convert it.
|
|
544
|
+
convertSymbol(context, context.resolveAliasedSymbol(symbol), exportSymbol ?? symbol);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
createAlias(reflection, context, symbol, exportSymbol);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function createAlias(target, context, symbol, exportSymbol) {
|
|
552
|
+
if (context.converter.excludeReferences)
|
|
553
|
+
return;
|
|
554
|
+
// We already have this. Create a reference.
|
|
555
|
+
const ref = new ReferenceReflection(exportSymbol?.name ?? symbol.name, target.isReference() ? target.getTargetReflection() : target, context.scope);
|
|
556
|
+
context.postReflectionCreation(ref, symbol, exportSymbol);
|
|
557
|
+
context.finalizeDeclarationReflection(ref);
|
|
558
|
+
}
|
|
559
|
+
function convertVariable(context, symbol, exportSymbol) {
|
|
560
|
+
if (isTypeOnlyExport(exportSymbol)) {
|
|
561
|
+
return convertTypeAliasFromValueDeclaration(context, symbol, exportSymbol, ReflectionKind.Variable);
|
|
562
|
+
}
|
|
563
|
+
const declaration = symbol.getDeclarations()?.[0];
|
|
564
|
+
const comment = context.getComment(symbol, ReflectionKind.Variable);
|
|
565
|
+
const type = declaration
|
|
566
|
+
? context.checker.getTypeOfSymbolAtLocation(symbol, declaration)
|
|
567
|
+
: context.checker.getTypeOfSymbol(symbol);
|
|
568
|
+
if (isEnumLike(context.checker, type, declaration) &&
|
|
569
|
+
comment?.hasModifier("@enum")) {
|
|
570
|
+
return convertVariableAsEnum(context, symbol, exportSymbol);
|
|
571
|
+
}
|
|
572
|
+
if (comment?.hasModifier("@namespace")) {
|
|
573
|
+
return convertVariableAsNamespace(context, symbol, exportSymbol);
|
|
574
|
+
}
|
|
575
|
+
if (comment?.hasModifier("@class")) {
|
|
576
|
+
return convertSymbolAsClass(context, symbol, exportSymbol);
|
|
577
|
+
}
|
|
578
|
+
if (type.getCallSignatures().length &&
|
|
579
|
+
!type.getConstructSignatures().length) {
|
|
580
|
+
if (comment?.hasModifier("@function") ||
|
|
581
|
+
(declaration && shouldAutomaticallyConvertAsFunction(declaration))) {
|
|
582
|
+
return convertVariableAsFunction(context, symbol, exportSymbol);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.VariableContainer)
|
|
586
|
+
? ReflectionKind.Variable
|
|
587
|
+
: ReflectionKind.Property, symbol, exportSymbol);
|
|
588
|
+
let typeNode;
|
|
589
|
+
if (declaration && ts.isVariableDeclaration(declaration)) {
|
|
590
|
+
// Otherwise we might have destructuring
|
|
591
|
+
typeNode = declaration.type;
|
|
592
|
+
}
|
|
593
|
+
if (typeNode) {
|
|
594
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), typeNode);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), type, typeNode);
|
|
598
|
+
}
|
|
599
|
+
setModifiers(symbol, declaration, reflection);
|
|
600
|
+
reflection.defaultValue = convertDefaultValue(declaration);
|
|
601
|
+
context.finalizeDeclarationReflection(reflection);
|
|
602
|
+
// Exclude ValueModule to handle `module.exports = []`
|
|
603
|
+
return ts.SymbolFlags.Property | ts.SymbolFlags.ValueModule;
|
|
604
|
+
}
|
|
605
|
+
function isEnumLike(checker, type, location) {
|
|
606
|
+
if (!location || !hasAllFlags(type.flags, ts.TypeFlags.Object)) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
return type.getProperties().every((prop) => {
|
|
610
|
+
const propType = checker.getTypeOfSymbolAtLocation(prop, location);
|
|
611
|
+
return isValidEnumProperty(propType);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
function isValidEnumProperty(type) {
|
|
615
|
+
return hasAnyFlag(type.flags, ts.TypeFlags.NumberLike | ts.TypeFlags.StringLike);
|
|
616
|
+
}
|
|
617
|
+
function convertVariableAsEnum(context, symbol, exportSymbol) {
|
|
618
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Enum, symbol, exportSymbol);
|
|
619
|
+
context.finalizeDeclarationReflection(reflection);
|
|
620
|
+
const rc = context.withScope(reflection);
|
|
621
|
+
const declaration = symbol.valueDeclaration;
|
|
622
|
+
if (!declaration) {
|
|
623
|
+
context.logger.error(i18n.converting_0_as_enum_requires_value_declaration(symbol.name), symbol.declarations?.[0]);
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const type = context.checker.getTypeAtLocation(declaration);
|
|
627
|
+
for (const prop of type.getProperties()) {
|
|
628
|
+
const reflection = rc.createDeclarationReflection(ReflectionKind.EnumMember, prop, void 0);
|
|
629
|
+
const propType = context.checker.getTypeOfSymbolAtLocation(prop, declaration);
|
|
630
|
+
reflection.type = context.converter.convertType(rc.withScope(reflection), propType);
|
|
631
|
+
rc.finalizeDeclarationReflection(reflection);
|
|
632
|
+
}
|
|
633
|
+
// Skip converting the type alias, if there is one
|
|
634
|
+
return ts.SymbolFlags.TypeAlias;
|
|
635
|
+
}
|
|
636
|
+
function convertVariableAsNamespace(context, symbol, exportSymbol) {
|
|
637
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Namespace, symbol, exportSymbol);
|
|
638
|
+
context.finalizeDeclarationReflection(reflection);
|
|
639
|
+
const rc = context.withScope(reflection);
|
|
640
|
+
const type = context.checker.getTypeOfSymbol(symbol);
|
|
641
|
+
convertSymbols(rc, type.getProperties());
|
|
642
|
+
return ts.SymbolFlags.Property;
|
|
643
|
+
}
|
|
644
|
+
function convertVariableAsFunction(context, symbol, exportSymbol) {
|
|
645
|
+
const declaration = symbol
|
|
646
|
+
.getDeclarations()
|
|
647
|
+
?.find(ts.isVariableDeclaration);
|
|
648
|
+
const accessDeclaration = declaration ?? symbol.valueDeclaration;
|
|
649
|
+
const type = accessDeclaration
|
|
650
|
+
? context.checker.getTypeOfSymbolAtLocation(symbol, accessDeclaration)
|
|
651
|
+
: context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
652
|
+
const reflection = context.createDeclarationReflection(context.scope.kindOf(ReflectionKind.MethodContainer)
|
|
653
|
+
? ReflectionKind.Method
|
|
654
|
+
: ReflectionKind.Function, symbol, exportSymbol);
|
|
655
|
+
setModifiers(symbol, accessDeclaration, reflection);
|
|
656
|
+
context.finalizeDeclarationReflection(reflection);
|
|
657
|
+
const reflectionContext = context.withScope(reflection);
|
|
658
|
+
reflection.signatures ??= [];
|
|
659
|
+
for (const signature of type.getCallSignatures()) {
|
|
660
|
+
createSignature(reflectionContext, ReflectionKind.CallSignature, signature, symbol);
|
|
661
|
+
}
|
|
662
|
+
reflection.comment?.removeModifier("@function");
|
|
663
|
+
// #2824 If there is only one signature, and there isn't a comment
|
|
664
|
+
// on the signature already, treat the comment on the variable
|
|
665
|
+
// as if it belongs to the signature instead.
|
|
666
|
+
if (reflection.signatures.length === 1 &&
|
|
667
|
+
!reflection.signatures[0].comment &&
|
|
668
|
+
reflection.comment) {
|
|
669
|
+
reflection.signatures[0].comment = reflection.comment;
|
|
670
|
+
delete reflection.comment;
|
|
671
|
+
}
|
|
672
|
+
return (convertFunctionProperties(context.withScope(reflection), symbol, type) |
|
|
673
|
+
ts.SymbolFlags.Property);
|
|
674
|
+
}
|
|
675
|
+
function convertFunctionProperties(context, symbol, type) {
|
|
676
|
+
// #2436/#2461: Functions created with Object.assign on a function likely have properties
|
|
677
|
+
// that we should document. We also add properties to the function if they are defined like:
|
|
678
|
+
// function f() {}
|
|
679
|
+
// f.x = 123;
|
|
680
|
+
// rather than creating a separate namespace.
|
|
681
|
+
// In the expando case, we'll have both namespace flags.
|
|
682
|
+
// In the Object.assign case, we'll have no namespace flags.
|
|
683
|
+
const nsFlags = ts.SymbolFlags.ValueModule | ts.SymbolFlags.NamespaceModule;
|
|
684
|
+
if (type.getProperties().length &&
|
|
685
|
+
(hasAllFlags(symbol.flags, nsFlags) ||
|
|
686
|
+
!hasAnyFlag(symbol.flags, nsFlags)) &&
|
|
687
|
+
!symbol.declarations?.some(ts.isModuleDeclaration)) {
|
|
688
|
+
convertSymbols(context, type.getProperties());
|
|
689
|
+
return ts.SymbolFlags.NamespaceModule;
|
|
690
|
+
}
|
|
691
|
+
return ts.SymbolFlags.None;
|
|
692
|
+
}
|
|
693
|
+
function convertSymbolAsClass(context, symbol, exportSymbol) {
|
|
694
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Class, symbol, exportSymbol);
|
|
695
|
+
const rc = context.withScope(reflection);
|
|
696
|
+
context.finalizeDeclarationReflection(reflection);
|
|
697
|
+
if (!symbol.valueDeclaration) {
|
|
698
|
+
context.logger.error(i18n.converting_0_as_class_requires_value_declaration(symbol.name), symbol.declarations?.[0]);
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const type = context.checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
702
|
+
rc.shouldBeStatic = true;
|
|
703
|
+
convertSymbols(rc,
|
|
704
|
+
// Prototype is implicitly this class, don't document it.
|
|
705
|
+
type.getProperties().filter((prop) => prop.name !== "prototype"));
|
|
706
|
+
for (const sig of type.getCallSignatures()) {
|
|
707
|
+
createSignature(rc, ReflectionKind.CallSignature, sig, undefined);
|
|
708
|
+
}
|
|
709
|
+
rc.shouldBeStatic = false;
|
|
710
|
+
const ctors = type.getConstructSignatures();
|
|
711
|
+
if (ctors.length) {
|
|
712
|
+
const constructMember = rc.createDeclarationReflection(ReflectionKind.Constructor, ctors[0]?.declaration?.symbol, void 0, "constructor");
|
|
713
|
+
// Modifiers are the same for all constructors
|
|
714
|
+
if (ctors.length && ctors[0].declaration) {
|
|
715
|
+
setModifiers(symbol, ctors[0].declaration, constructMember);
|
|
716
|
+
}
|
|
717
|
+
context.finalizeDeclarationReflection(constructMember);
|
|
718
|
+
const constructContext = rc.withScope(constructMember);
|
|
719
|
+
for (const sig of ctors) {
|
|
720
|
+
createConstructSignatureWithType(constructContext, sig, reflection);
|
|
721
|
+
}
|
|
722
|
+
// Take the type parameters from the first constructor signature and use
|
|
723
|
+
// them as the type parameters for the class, #2914
|
|
724
|
+
reflection.typeParameters = convertTypeParameters(rc, reflection, ctors[0].getTypeParameters());
|
|
725
|
+
const instType = ctors[0].getReturnType();
|
|
726
|
+
convertSymbols(rc, instType.getProperties());
|
|
727
|
+
for (const sig of instType.getCallSignatures()) {
|
|
728
|
+
createSignature(rc, ReflectionKind.CallSignature, sig, undefined);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
context.logger.warn(i18n.converting_0_as_class_without_construct_signatures(reflection.getFriendlyFullName()), symbol.valueDeclaration);
|
|
733
|
+
}
|
|
734
|
+
return (ts.SymbolFlags.TypeAlias |
|
|
735
|
+
ts.SymbolFlags.Interface |
|
|
736
|
+
ts.SymbolFlags.Namespace);
|
|
737
|
+
}
|
|
738
|
+
function convertAccessor(context, symbol, exportSymbol) {
|
|
739
|
+
const reflection = context.createDeclarationReflection(ReflectionKind.Accessor, symbol, exportSymbol);
|
|
740
|
+
const rc = context.withScope(reflection);
|
|
741
|
+
const declaration = symbol.getDeclarations()?.[0];
|
|
742
|
+
if (declaration) {
|
|
743
|
+
setModifiers(symbol, declaration, reflection);
|
|
744
|
+
// #3019, auto accessors `accessor x: string` get the symbol flag for
|
|
745
|
+
// an accessor, but they don't have get/set accessors, so the need a type
|
|
746
|
+
// set on the accessor reflection structure.
|
|
747
|
+
if (ts.isPropertyDeclaration(declaration) &&
|
|
748
|
+
declaration.modifiers?.some(n => n.kind === ts.SyntaxKind.AccessorKeyword)) {
|
|
749
|
+
reflection.type = context.converter.convertType(context.withScope(reflection), context.checker.getTypeOfSymbol(symbol), declaration.type);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
context.finalizeDeclarationReflection(reflection);
|
|
753
|
+
const getDeclaration = symbol.getDeclarations()?.find(ts.isGetAccessor);
|
|
754
|
+
if (getDeclaration) {
|
|
755
|
+
const signature = context.checker.getSignatureFromDeclaration(getDeclaration);
|
|
756
|
+
if (signature) {
|
|
757
|
+
createSignature(rc, ReflectionKind.GetSignature, signature, symbol, getDeclaration);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
const setDeclaration = symbol.getDeclarations()?.find(ts.isSetAccessor);
|
|
761
|
+
if (setDeclaration) {
|
|
762
|
+
const signature = context.checker.getSignatureFromDeclaration(setDeclaration);
|
|
763
|
+
if (signature) {
|
|
764
|
+
createSignature(rc, ReflectionKind.SetSignature, signature, symbol, setDeclaration);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
function isInherited(context, symbol) {
|
|
769
|
+
const parentSymbol = context.getSymbolFromReflection(context.scope);
|
|
770
|
+
// It'd be nice to be able to assert that this is true, but sometimes object
|
|
771
|
+
// types don't get symbols if they are inferred.
|
|
772
|
+
if (!parentSymbol)
|
|
773
|
+
return false;
|
|
774
|
+
const parents = parentSymbol.declarations?.slice() || [];
|
|
775
|
+
const constructorDecls = parents.flatMap((parent) => ts.isClassDeclaration(parent)
|
|
776
|
+
? parent.members.filter(ts.isConstructorDeclaration)
|
|
777
|
+
: []);
|
|
778
|
+
parents.push(...constructorDecls);
|
|
779
|
+
return (parents.some((d) => symbol.getDeclarations()?.some((d2) => d2.parent === d)) === false);
|
|
780
|
+
}
|
|
781
|
+
function setModifiers(symbol, declaration, reflection) {
|
|
782
|
+
setSymbolModifiers(symbol, reflection);
|
|
783
|
+
if (!declaration) {
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
const modifiers = ts.getCombinedModifierFlags(declaration);
|
|
787
|
+
if (ts.isMethodDeclaration(declaration) ||
|
|
788
|
+
ts.isPropertyDeclaration(declaration) ||
|
|
789
|
+
ts.isAccessor(declaration)) {
|
|
790
|
+
if (ts.isPrivateIdentifier(declaration.name)) {
|
|
791
|
+
reflection.setFlag(ReflectionFlag.Private);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (hasAllFlags(modifiers, ts.ModifierFlags.Private)) {
|
|
795
|
+
reflection.setFlag(ReflectionFlag.Private);
|
|
796
|
+
}
|
|
797
|
+
if (hasAllFlags(modifiers, ts.ModifierFlags.Protected)) {
|
|
798
|
+
reflection.setFlag(ReflectionFlag.Protected);
|
|
799
|
+
}
|
|
800
|
+
if (hasAllFlags(modifiers, ts.ModifierFlags.Public)) {
|
|
801
|
+
reflection.setFlag(ReflectionFlag.Public);
|
|
802
|
+
}
|
|
803
|
+
reflection.setFlag(ReflectionFlag.Optional, hasAllFlags(symbol.flags, ts.SymbolFlags.Optional));
|
|
804
|
+
reflection.setFlag(ReflectionFlag.Readonly, hasAllFlags(ts.getCheckFlags(symbol), ts.CheckFlags.Readonly) ||
|
|
805
|
+
hasAllFlags(modifiers, ts.ModifierFlags.Readonly));
|
|
806
|
+
reflection.setFlag(ReflectionFlag.Abstract, hasAllFlags(modifiers, ts.ModifierFlags.Abstract));
|
|
807
|
+
if (reflection.kindOf(ReflectionKind.Variable) &&
|
|
808
|
+
hasAllFlags(symbol.flags, ts.SymbolFlags.BlockScopedVariable)) {
|
|
809
|
+
reflection.setFlag(ReflectionFlag.Const, hasAllFlags(declaration.parent.flags, ts.NodeFlags.Const));
|
|
810
|
+
}
|
|
811
|
+
// ReflectionFlag.Static happens when constructing the reflection.
|
|
812
|
+
// We don't have sufficient information here to determine if it ought to be static.
|
|
813
|
+
}
|
|
814
|
+
function setSymbolModifiers(symbol, reflection) {
|
|
815
|
+
reflection.setFlag(ReflectionFlag.Optional, hasAllFlags(symbol.flags, ts.SymbolFlags.Optional));
|
|
816
|
+
}
|
|
817
|
+
function shouldAutomaticallyConvertAsFunction(node) {
|
|
818
|
+
// const fn = () => {}
|
|
819
|
+
if (ts.isVariableDeclaration(node)) {
|
|
820
|
+
if (node.type || !node.initializer)
|
|
821
|
+
return false;
|
|
822
|
+
return isFunctionLikeInitializer(node.initializer);
|
|
823
|
+
}
|
|
824
|
+
// { fn: () => {} }
|
|
825
|
+
if (ts.isPropertyAssignment(node)) {
|
|
826
|
+
return isFunctionLikeInitializer(node.initializer);
|
|
827
|
+
}
|
|
828
|
+
// exports.fn = () => {}
|
|
829
|
+
// exports.fn ||= () => {}
|
|
830
|
+
// exports.fn ??= () => {}
|
|
831
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
832
|
+
if (ts.isBinaryExpression(node.parent) &&
|
|
833
|
+
[ts.SyntaxKind.EqualsToken, ts.SyntaxKind.BarBarEqualsToken, ts.SyntaxKind.QuestionQuestionEqualsToken]
|
|
834
|
+
.includes(node.parent.operatorToken.kind)) {
|
|
835
|
+
return isFunctionLikeInitializer(node.parent.right);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
function isFunctionLikeInitializer(node) {
|
|
841
|
+
if (ts.isFunctionExpression(node) || ts.isArrowFunction(node)) {
|
|
842
|
+
return true;
|
|
843
|
+
}
|
|
844
|
+
if (ts.isSatisfiesExpression(node)) {
|
|
845
|
+
return isFunctionLikeInitializer(node.expression);
|
|
846
|
+
}
|
|
847
|
+
if (ts.isAsExpression(node)) {
|
|
848
|
+
return isFunctionLikeInitializer(node.expression);
|
|
849
|
+
}
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
function isTypeOnlyExport(symbol) {
|
|
853
|
+
if (!symbol)
|
|
854
|
+
return false;
|
|
855
|
+
const declaration = symbol.declarations?.[0];
|
|
856
|
+
if (!declaration)
|
|
857
|
+
return false;
|
|
858
|
+
if (!ts.isExportSpecifier(declaration))
|
|
859
|
+
return false;
|
|
860
|
+
return declaration.isTypeOnly || declaration.parent.parent.isTypeOnly;
|
|
861
|
+
}
|