@microsoft/api-extractor 7.56.2 → 7.57.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/CHANGELOG.json +41 -0
- package/CHANGELOG.md +15 -1
- package/bin/api-extractor +1 -1
- package/lib-esm/aedoc/PackageDocComment.js +56 -0
- package/lib-esm/aedoc/PackageDocComment.js.map +1 -0
- package/lib-esm/analyzer/AstDeclaration.js +214 -0
- package/lib-esm/analyzer/AstDeclaration.js.map +1 -0
- package/lib-esm/analyzer/AstEntity.js +35 -0
- package/lib-esm/analyzer/AstEntity.js.map +1 -0
- package/lib-esm/analyzer/AstImport.js +76 -0
- package/lib-esm/analyzer/AstImport.js.map +1 -0
- package/lib-esm/analyzer/AstModule.js +22 -0
- package/lib-esm/analyzer/AstModule.js.map +1 -0
- package/lib-esm/analyzer/AstNamespaceExport.js +38 -0
- package/lib-esm/analyzer/AstNamespaceExport.js.map +1 -0
- package/lib-esm/analyzer/AstNamespaceImport.js +57 -0
- package/lib-esm/analyzer/AstNamespaceImport.js.map +1 -0
- package/lib-esm/analyzer/AstReferenceResolver.js +202 -0
- package/lib-esm/analyzer/AstReferenceResolver.js.map +1 -0
- package/lib-esm/analyzer/AstSymbol.js +104 -0
- package/lib-esm/analyzer/AstSymbol.js.map +1 -0
- package/lib-esm/analyzer/AstSymbolTable.js +524 -0
- package/lib-esm/analyzer/AstSymbolTable.js.map +1 -0
- package/lib-esm/analyzer/ExportAnalyzer.js +725 -0
- package/lib-esm/analyzer/ExportAnalyzer.js.map +1 -0
- package/lib-esm/analyzer/PackageMetadataManager.js +235 -0
- package/lib-esm/analyzer/PackageMetadataManager.js.map +1 -0
- package/lib-esm/analyzer/SourceFileLocationFormatter.js +44 -0
- package/lib-esm/analyzer/SourceFileLocationFormatter.js.map +1 -0
- package/lib-esm/analyzer/Span.js +545 -0
- package/lib-esm/analyzer/Span.js.map +1 -0
- package/lib-esm/analyzer/SyntaxHelpers.js +72 -0
- package/lib-esm/analyzer/SyntaxHelpers.js.map +1 -0
- package/lib-esm/analyzer/TypeScriptHelpers.js +242 -0
- package/lib-esm/analyzer/TypeScriptHelpers.js.map +1 -0
- package/lib-esm/analyzer/TypeScriptInternals.js +114 -0
- package/lib-esm/analyzer/TypeScriptInternals.js.map +1 -0
- package/lib-esm/api/CompilerState.js +149 -0
- package/lib-esm/api/CompilerState.js.map +1 -0
- package/lib-esm/api/ConsoleMessageId.js +82 -0
- package/lib-esm/api/ConsoleMessageId.js.map +1 -0
- package/lib-esm/api/Extractor.js +290 -0
- package/lib-esm/api/Extractor.js.map +1 -0
- package/lib-esm/api/ExtractorConfig.js +801 -0
- package/lib-esm/api/ExtractorConfig.js.map +1 -0
- package/lib-esm/api/ExtractorLogLevel.js +46 -0
- package/lib-esm/api/ExtractorLogLevel.js.map +1 -0
- package/lib-esm/api/ExtractorMessage.js +140 -0
- package/lib-esm/api/ExtractorMessage.js.map +1 -0
- package/lib-esm/api/ExtractorMessageId.js +128 -0
- package/lib-esm/api/ExtractorMessageId.js.map +1 -0
- package/lib-esm/api/IConfigFile.js +4 -0
- package/lib-esm/api/IConfigFile.js.map +1 -0
- package/lib-esm/cli/ApiExtractorCommandLine.js +51 -0
- package/lib-esm/cli/ApiExtractorCommandLine.js.map +1 -0
- package/lib-esm/cli/InitAction.js +35 -0
- package/lib-esm/cli/InitAction.js.map +1 -0
- package/lib-esm/cli/RunAction.js +123 -0
- package/lib-esm/cli/RunAction.js.map +1 -0
- package/lib-esm/collector/ApiItemMetadata.js +55 -0
- package/lib-esm/collector/ApiItemMetadata.js.map +1 -0
- package/lib-esm/collector/Collector.js +794 -0
- package/lib-esm/collector/Collector.js.map +1 -0
- package/lib-esm/collector/CollectorEntity.js +219 -0
- package/lib-esm/collector/CollectorEntity.js.map +1 -0
- package/lib-esm/collector/DeclarationMetadata.js +24 -0
- package/lib-esm/collector/DeclarationMetadata.js.map +1 -0
- package/lib-esm/collector/MessageRouter.js +476 -0
- package/lib-esm/collector/MessageRouter.js.map +1 -0
- package/lib-esm/collector/SourceMapper.js +171 -0
- package/lib-esm/collector/SourceMapper.js.map +1 -0
- package/lib-esm/collector/SymbolMetadata.js +12 -0
- package/lib-esm/collector/SymbolMetadata.js.map +1 -0
- package/lib-esm/collector/VisitorState.js +23 -0
- package/lib-esm/collector/VisitorState.js.map +1 -0
- package/lib-esm/collector/WorkingPackage.js +30 -0
- package/lib-esm/collector/WorkingPackage.js.map +1 -0
- package/lib-esm/enhancers/DocCommentEnhancer.js +213 -0
- package/lib-esm/enhancers/DocCommentEnhancer.js.map +1 -0
- package/lib-esm/enhancers/ValidationEnhancer.js +217 -0
- package/lib-esm/enhancers/ValidationEnhancer.js.map +1 -0
- package/lib-esm/generators/ApiModelGenerator.js +852 -0
- package/lib-esm/generators/ApiModelGenerator.js.map +1 -0
- package/lib-esm/generators/ApiReportGenerator.js +518 -0
- package/lib-esm/generators/ApiReportGenerator.js.map +1 -0
- package/lib-esm/generators/DeclarationReferenceGenerator.js +292 -0
- package/lib-esm/generators/DeclarationReferenceGenerator.js.map +1 -0
- package/lib-esm/generators/DtsEmitHelpers.js +227 -0
- package/lib-esm/generators/DtsEmitHelpers.js.map +1 -0
- package/lib-esm/generators/DtsRollupGenerator.js +391 -0
- package/lib-esm/generators/DtsRollupGenerator.js.map +1 -0
- package/lib-esm/generators/ExcerptBuilder.js +259 -0
- package/lib-esm/generators/ExcerptBuilder.js.map +1 -0
- package/lib-esm/generators/IndentedWriter.js +238 -0
- package/lib-esm/generators/IndentedWriter.js.map +1 -0
- package/lib-esm/index.js +17 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/schemas/api-extractor-defaults.json +94 -0
- package/lib-esm/schemas/api-extractor-template.json +454 -0
- package/lib-esm/schemas/api-extractor.schema.json +257 -0
- package/lib-esm/start.js +14 -0
- package/lib-esm/start.js.map +1 -0
- package/package.json +38 -12
- /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js +0 -0
- /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstEntity.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstEntity.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstImport.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstImport.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstModule.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstModule.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstSymbol.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstSymbol.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/Span.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/Span.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js.map +0 -0
- /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js +0 -0
- /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js.map +0 -0
- /package/{lib → lib-commonjs}/api/CompilerState.js +0 -0
- /package/{lib → lib-commonjs}/api/CompilerState.js.map +0 -0
- /package/{lib → lib-commonjs}/api/ConsoleMessageId.js +0 -0
- /package/{lib → lib-commonjs}/api/ConsoleMessageId.js.map +0 -0
- /package/{lib → lib-commonjs}/api/Extractor.js +0 -0
- /package/{lib → lib-commonjs}/api/Extractor.js.map +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorConfig.js +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorConfig.js.map +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js.map +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorMessage.js +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorMessage.js.map +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorMessageId.js +0 -0
- /package/{lib → lib-commonjs}/api/ExtractorMessageId.js.map +0 -0
- /package/{lib → lib-commonjs}/api/IConfigFile.js +0 -0
- /package/{lib → lib-commonjs}/api/IConfigFile.js.map +0 -0
- /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js +0 -0
- /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js.map +0 -0
- /package/{lib → lib-commonjs}/cli/InitAction.js +0 -0
- /package/{lib → lib-commonjs}/cli/InitAction.js.map +0 -0
- /package/{lib → lib-commonjs}/cli/RunAction.js +0 -0
- /package/{lib → lib-commonjs}/cli/RunAction.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js +0 -0
- /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/Collector.js +0 -0
- /package/{lib → lib-commonjs}/collector/Collector.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/CollectorEntity.js +0 -0
- /package/{lib → lib-commonjs}/collector/CollectorEntity.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js +0 -0
- /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/MessageRouter.js +0 -0
- /package/{lib → lib-commonjs}/collector/MessageRouter.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/SourceMapper.js +0 -0
- /package/{lib → lib-commonjs}/collector/SourceMapper.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/SymbolMetadata.js +0 -0
- /package/{lib → lib-commonjs}/collector/SymbolMetadata.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/VisitorState.js +0 -0
- /package/{lib → lib-commonjs}/collector/VisitorState.js.map +0 -0
- /package/{lib → lib-commonjs}/collector/WorkingPackage.js +0 -0
- /package/{lib → lib-commonjs}/collector/WorkingPackage.js.map +0 -0
- /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js +0 -0
- /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js.map +0 -0
- /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js +0 -0
- /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js +0 -0
- /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js +0 -0
- /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js +0 -0
- /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js +0 -0
- /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js +0 -0
- /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js +0 -0
- /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js.map +0 -0
- /package/{lib → lib-commonjs}/generators/IndentedWriter.js +0 -0
- /package/{lib → lib-commonjs}/generators/IndentedWriter.js.map +0 -0
- /package/{lib → lib-commonjs}/index.js +0 -0
- /package/{lib → lib-commonjs}/index.js.map +0 -0
- /package/{lib → lib-commonjs}/schemas/api-extractor-defaults.json +0 -0
- /package/{lib → lib-commonjs}/schemas/api-extractor-template.json +0 -0
- /package/{lib → lib-commonjs}/schemas/api-extractor.schema.json +0 -0
- /package/{lib → lib-commonjs}/start.js +0 -0
- /package/{lib → lib-commonjs}/start.js.map +0 -0
- /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts +0 -0
- /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstEntity.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstEntity.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstImport.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstImport.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstModule.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstModule.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/Span.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/Span.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts.map +0 -0
- /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts +0 -0
- /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/CompilerState.d.ts +0 -0
- /package/{lib → lib-dts}/api/CompilerState.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts +0 -0
- /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/Extractor.d.ts +0 -0
- /package/{lib → lib-dts}/api/Extractor.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/ExtractorConfig.d.ts +0 -0
- /package/{lib → lib-dts}/api/ExtractorConfig.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts +0 -0
- /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/ExtractorMessage.d.ts +0 -0
- /package/{lib → lib-dts}/api/ExtractorMessage.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts +0 -0
- /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts.map +0 -0
- /package/{lib → lib-dts}/api/IConfigFile.d.ts +0 -0
- /package/{lib → lib-dts}/api/IConfigFile.d.ts.map +0 -0
- /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts +0 -0
- /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts.map +0 -0
- /package/{lib → lib-dts}/cli/InitAction.d.ts +0 -0
- /package/{lib → lib-dts}/cli/InitAction.d.ts.map +0 -0
- /package/{lib → lib-dts}/cli/RunAction.d.ts +0 -0
- /package/{lib → lib-dts}/cli/RunAction.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts +0 -0
- /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/Collector.d.ts +0 -0
- /package/{lib → lib-dts}/collector/Collector.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/CollectorEntity.d.ts +0 -0
- /package/{lib → lib-dts}/collector/CollectorEntity.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts +0 -0
- /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/MessageRouter.d.ts +0 -0
- /package/{lib → lib-dts}/collector/MessageRouter.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/SourceMapper.d.ts +0 -0
- /package/{lib → lib-dts}/collector/SourceMapper.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts +0 -0
- /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/VisitorState.d.ts +0 -0
- /package/{lib → lib-dts}/collector/VisitorState.d.ts.map +0 -0
- /package/{lib → lib-dts}/collector/WorkingPackage.d.ts +0 -0
- /package/{lib → lib-dts}/collector/WorkingPackage.d.ts.map +0 -0
- /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts +0 -0
- /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts.map +0 -0
- /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts +0 -0
- /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts +0 -0
- /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts +0 -0
- /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts +0 -0
- /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts +0 -0
- /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts +0 -0
- /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts +0 -0
- /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts.map +0 -0
- /package/{lib → lib-dts}/generators/IndentedWriter.d.ts +0 -0
- /package/{lib → lib-dts}/generators/IndentedWriter.d.ts.map +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts.map +0 -0
- /package/{lib → lib-dts}/start.d.ts +0 -0
- /package/{lib → lib-dts}/start.d.ts.map +0 -0
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
|
+
import { minimatch } from 'minimatch';
|
|
5
|
+
import * as tsdoc from '@microsoft/tsdoc';
|
|
6
|
+
import { ReleaseTag } from '@microsoft/api-extractor-model';
|
|
7
|
+
import { PackageJsonLookup, Sort, InternalError, PackageName } from '@rushstack/node-core-library';
|
|
8
|
+
import { ExtractorMessageId } from '../api/ExtractorMessageId';
|
|
9
|
+
import { CollectorEntity } from './CollectorEntity';
|
|
10
|
+
import { AstSymbolTable } from '../analyzer/AstSymbolTable';
|
|
11
|
+
import { AstSymbol } from '../analyzer/AstSymbol';
|
|
12
|
+
import { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';
|
|
13
|
+
import { WorkingPackage } from './WorkingPackage';
|
|
14
|
+
import { PackageDocComment } from '../aedoc/PackageDocComment';
|
|
15
|
+
import { InternalDeclarationMetadata } from './DeclarationMetadata';
|
|
16
|
+
import { ApiItemMetadata } from './ApiItemMetadata';
|
|
17
|
+
import { SymbolMetadata } from './SymbolMetadata';
|
|
18
|
+
import { TypeScriptInternals } from '../analyzer/TypeScriptInternals';
|
|
19
|
+
import { AstReferenceResolver } from '../analyzer/AstReferenceResolver';
|
|
20
|
+
import { ExtractorConfig } from '../api/ExtractorConfig';
|
|
21
|
+
import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
|
|
22
|
+
import { AstImport } from '../analyzer/AstImport';
|
|
23
|
+
/**
|
|
24
|
+
* The `Collector` manages the overall data set that is used by `ApiModelGenerator`,
|
|
25
|
+
* `DtsRollupGenerator`, and `ApiReportGenerator`. Starting from the working package's entry point,
|
|
26
|
+
* the `Collector` collects all exported symbols, determines how to import any symbols they reference,
|
|
27
|
+
* assigns unique names, and sorts everything into a normalized alphabetical ordering.
|
|
28
|
+
*/
|
|
29
|
+
export class Collector {
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this._entities = [];
|
|
32
|
+
this._entitiesByAstEntity = new Map();
|
|
33
|
+
this._entitiesBySymbol = new Map();
|
|
34
|
+
this._starExportedExternalModulePaths = [];
|
|
35
|
+
this._dtsTypeReferenceDirectives = new Set();
|
|
36
|
+
this._dtsLibReferenceDirectives = new Set();
|
|
37
|
+
this.packageJsonLookup = new PackageJsonLookup();
|
|
38
|
+
this._program = options.program;
|
|
39
|
+
this.extractorConfig = options.extractorConfig;
|
|
40
|
+
this.sourceMapper = options.sourceMapper;
|
|
41
|
+
const entryPointSourceFile = options.program.getSourceFile(this.extractorConfig.mainEntryPointFilePath);
|
|
42
|
+
if (!entryPointSourceFile) {
|
|
43
|
+
throw new Error('Unable to load file: ' + this.extractorConfig.mainEntryPointFilePath);
|
|
44
|
+
}
|
|
45
|
+
if (!this.extractorConfig.packageFolder || !this.extractorConfig.packageJson) {
|
|
46
|
+
// TODO: We should be able to analyze projects that don't have any package.json.
|
|
47
|
+
// The ExtractorConfig class is already designed to allow this.
|
|
48
|
+
throw new Error('Unable to find a package.json file for the project being analyzed');
|
|
49
|
+
}
|
|
50
|
+
this.workingPackage = new WorkingPackage({
|
|
51
|
+
packageFolder: this.extractorConfig.packageFolder,
|
|
52
|
+
packageJson: this.extractorConfig.packageJson,
|
|
53
|
+
entryPointSourceFile
|
|
54
|
+
});
|
|
55
|
+
this.messageRouter = options.messageRouter;
|
|
56
|
+
this.program = options.program;
|
|
57
|
+
this.typeChecker = options.program.getTypeChecker();
|
|
58
|
+
this.globalVariableAnalyzer = TypeScriptInternals.getGlobalVariableAnalyzer(this.program);
|
|
59
|
+
this._tsdocParser = new tsdoc.TSDocParser(this.extractorConfig.tsdocConfiguration);
|
|
60
|
+
// Resolve package name patterns and store concrete set of bundled package dependency names
|
|
61
|
+
this.bundledPackageNames = Collector._resolveBundledPackagePatterns(this.extractorConfig.bundledPackages, this.extractorConfig.packageJson);
|
|
62
|
+
this.astSymbolTable = new AstSymbolTable(this.program, this.typeChecker, this.packageJsonLookup, this.bundledPackageNames, this.messageRouter);
|
|
63
|
+
this.astReferenceResolver = new AstReferenceResolver(this);
|
|
64
|
+
this._cachedOverloadIndexesByDeclaration = new Map();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve provided `bundledPackages` names and glob patterns to a list of explicit package names.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* Explicit package names will be included in the output unconditionally. However, wildcard patterns will
|
|
71
|
+
* only be matched against the various dependencies listed in the provided package.json (if there was one).
|
|
72
|
+
* Patterns will be matched against `dependencies`, `devDependencies`, `optionalDependencies`, and `peerDependencies`.
|
|
73
|
+
*
|
|
74
|
+
* @param bundledPackages - The list of package names and/or glob patterns to resolve.
|
|
75
|
+
* @param packageJson - The package.json of the package being processed (if there is one).
|
|
76
|
+
* @returns The set of resolved package names to be bundled during analysis.
|
|
77
|
+
*/
|
|
78
|
+
static _resolveBundledPackagePatterns(bundledPackages, packageJson) {
|
|
79
|
+
var _a, _b, _c, _d;
|
|
80
|
+
if (bundledPackages.length === 0) {
|
|
81
|
+
// If no `bundledPackages` were specified, then there is nothing to resolve.
|
|
82
|
+
// Return an empty set.
|
|
83
|
+
return new Set();
|
|
84
|
+
}
|
|
85
|
+
// Accumulate all declared dependencies.
|
|
86
|
+
// Any wildcard patterns in `bundledPackages` will be resolved against these.
|
|
87
|
+
const dependencyNames = new Set();
|
|
88
|
+
Object.keys((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) !== null && _a !== void 0 ? _a : {}).forEach((dep) => dependencyNames.add(dep));
|
|
89
|
+
Object.keys((_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.devDependencies) !== null && _b !== void 0 ? _b : {}).forEach((dep) => dependencyNames.add(dep));
|
|
90
|
+
Object.keys((_c = packageJson === null || packageJson === void 0 ? void 0 : packageJson.peerDependencies) !== null && _c !== void 0 ? _c : {}).forEach((dep) => dependencyNames.add(dep));
|
|
91
|
+
Object.keys((_d = packageJson === null || packageJson === void 0 ? void 0 : packageJson.optionalDependencies) !== null && _d !== void 0 ? _d : {}).forEach((dep) => dependencyNames.add(dep));
|
|
92
|
+
// The set of resolved package names to be populated and returned
|
|
93
|
+
const resolvedPackageNames = new Set();
|
|
94
|
+
for (const packageNameOrPattern of bundledPackages) {
|
|
95
|
+
// If the string is an exact package name, use it regardless of package.json contents
|
|
96
|
+
if (PackageName.isValidName(packageNameOrPattern)) {
|
|
97
|
+
resolvedPackageNames.add(packageNameOrPattern);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// If the entry isn't an exact package name, assume glob pattern and search for matches
|
|
101
|
+
for (const dependencyName of dependencyNames) {
|
|
102
|
+
if (minimatch(dependencyName, packageNameOrPattern)) {
|
|
103
|
+
resolvedPackageNames.add(dependencyName);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return resolvedPackageNames;
|
|
109
|
+
}
|
|
110
|
+
/**a
|
|
111
|
+
* Returns a list of names (e.g. "example-library") that should appear in a reference like this:
|
|
112
|
+
*
|
|
113
|
+
* ```
|
|
114
|
+
* /// <reference types="example-library" />
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
get dtsTypeReferenceDirectives() {
|
|
118
|
+
return this._dtsTypeReferenceDirectives;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A list of names (e.g. "runtime-library") that should appear in a reference like this:
|
|
122
|
+
*
|
|
123
|
+
* ```
|
|
124
|
+
* /// <reference lib="runtime-library" />
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
get dtsLibReferenceDirectives() {
|
|
128
|
+
return this._dtsLibReferenceDirectives;
|
|
129
|
+
}
|
|
130
|
+
get entities() {
|
|
131
|
+
return this._entities;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A list of module specifiers (e.g. `"@rushstack/node-core-library/lib/FileSystem"`) that should be emitted
|
|
135
|
+
* as star exports (e.g. `export * from "@rushstack/node-core-library/lib/FileSystem"`).
|
|
136
|
+
*/
|
|
137
|
+
get starExportedExternalModulePaths() {
|
|
138
|
+
return this._starExportedExternalModulePaths;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Perform the analysis.
|
|
142
|
+
*/
|
|
143
|
+
analyze() {
|
|
144
|
+
if (this._astEntryPoint) {
|
|
145
|
+
throw new Error('DtsRollupGenerator.analyze() was already called');
|
|
146
|
+
}
|
|
147
|
+
// This runs a full type analysis, and then augments the Abstract Syntax Tree (i.e. declarations)
|
|
148
|
+
// with semantic information (i.e. symbols). The "diagnostics" are a subset of the everyday
|
|
149
|
+
// compile errors that would result from a full compilation.
|
|
150
|
+
for (const diagnostic of this._program.getSemanticDiagnostics()) {
|
|
151
|
+
this.messageRouter.addCompilerDiagnostic(diagnostic);
|
|
152
|
+
}
|
|
153
|
+
const sourceFiles = this.program.getSourceFiles();
|
|
154
|
+
if (this.messageRouter.showDiagnostics) {
|
|
155
|
+
this.messageRouter.logDiagnosticHeader('Root filenames');
|
|
156
|
+
for (const fileName of this.program.getRootFileNames()) {
|
|
157
|
+
this.messageRouter.logDiagnostic(fileName);
|
|
158
|
+
}
|
|
159
|
+
this.messageRouter.logDiagnosticFooter();
|
|
160
|
+
this.messageRouter.logDiagnosticHeader('Files analyzed by compiler');
|
|
161
|
+
for (const sourceFile of sourceFiles) {
|
|
162
|
+
this.messageRouter.logDiagnostic(sourceFile.fileName);
|
|
163
|
+
}
|
|
164
|
+
this.messageRouter.logDiagnosticFooter();
|
|
165
|
+
}
|
|
166
|
+
// We can throw this error earlier in CompilerState.ts, but intentionally wait until after we've logged the
|
|
167
|
+
// associated diagnostic message above to make debugging easier for developers.
|
|
168
|
+
// Typically there will be many such files -- to avoid too much noise, only report the first one.
|
|
169
|
+
const badSourceFile = sourceFiles.find(({ fileName }) => !ExtractorConfig.hasDtsFileExtension(fileName));
|
|
170
|
+
if (badSourceFile) {
|
|
171
|
+
this.messageRouter.addAnalyzerIssueForPosition(ExtractorMessageId.WrongInputFileType, 'Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension. ' +
|
|
172
|
+
'Troubleshooting tips: https://api-extractor.com/link/dts-error', badSourceFile, 0);
|
|
173
|
+
}
|
|
174
|
+
// Build the entry point
|
|
175
|
+
const entryPointSourceFile = this.workingPackage.entryPointSourceFile;
|
|
176
|
+
const astEntryPoint = this.astSymbolTable.fetchAstModuleFromWorkingPackage(entryPointSourceFile);
|
|
177
|
+
this._astEntryPoint = astEntryPoint;
|
|
178
|
+
const packageDocCommentTextRange = PackageDocComment.tryFindInSourceFile(entryPointSourceFile, this);
|
|
179
|
+
if (packageDocCommentTextRange) {
|
|
180
|
+
const range = tsdoc.TextRange.fromStringRange(entryPointSourceFile.text, packageDocCommentTextRange.pos, packageDocCommentTextRange.end);
|
|
181
|
+
this.workingPackage.tsdocParserContext = this._tsdocParser.parseRange(range);
|
|
182
|
+
this.messageRouter.addTsdocMessages(this.workingPackage.tsdocParserContext, entryPointSourceFile);
|
|
183
|
+
this.workingPackage.tsdocComment = this.workingPackage.tsdocParserContext.docComment;
|
|
184
|
+
}
|
|
185
|
+
const { exportedLocalEntities, starExportedExternalModules, visitedAstModules } = this.astSymbolTable.fetchAstModuleExportInfo(astEntryPoint);
|
|
186
|
+
// Create a CollectorEntity for each top-level export.
|
|
187
|
+
const processedAstEntities = [];
|
|
188
|
+
for (const [exportName, astEntity] of exportedLocalEntities) {
|
|
189
|
+
this._createCollectorEntity(astEntity, exportName);
|
|
190
|
+
processedAstEntities.push(astEntity);
|
|
191
|
+
}
|
|
192
|
+
// Recursively create the remaining CollectorEntities after the top-level entities
|
|
193
|
+
// have been processed.
|
|
194
|
+
const alreadySeenAstEntities = new Set();
|
|
195
|
+
for (const astEntity of processedAstEntities) {
|
|
196
|
+
this._recursivelyCreateEntities(astEntity, alreadySeenAstEntities);
|
|
197
|
+
if (astEntity instanceof AstSymbol) {
|
|
198
|
+
this.fetchSymbolMetadata(astEntity);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Ensure references are collected from any intermediate files that
|
|
202
|
+
// only include exports
|
|
203
|
+
const nonExternalSourceFiles = new Set();
|
|
204
|
+
for (const { sourceFile, isExternal } of visitedAstModules) {
|
|
205
|
+
if (!nonExternalSourceFiles.has(sourceFile) && !isExternal) {
|
|
206
|
+
nonExternalSourceFiles.add(sourceFile);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Here, we're collecting reference directives from all non-external source files
|
|
210
|
+
// that were encountered while looking for exports, but only those references that
|
|
211
|
+
// were explicitly written by the developer and marked with the `preserve="true"`
|
|
212
|
+
// attribute. In TS >= 5.5, only references that are explicitly authored and marked
|
|
213
|
+
// with `preserve="true"` are included in the output. See https://github.com/microsoft/TypeScript/pull/57681
|
|
214
|
+
//
|
|
215
|
+
// The `_collectReferenceDirectives` function pulls in all references in files that
|
|
216
|
+
// contain definitions, but does not examine files that only reexport from other
|
|
217
|
+
// files. Here, we're looking through files that were missed by `_collectReferenceDirectives`,
|
|
218
|
+
// but only collecting references that were explicitly marked with `preserve="true"`.
|
|
219
|
+
// It is intuitive for developers to include references that they explicitly want part of
|
|
220
|
+
// their public API in a file like the entrypoint, which is likely to only contain reexports,
|
|
221
|
+
// and this picks those up.
|
|
222
|
+
this._collectReferenceDirectivesFromSourceFiles(nonExternalSourceFiles, true);
|
|
223
|
+
this._makeUniqueNames();
|
|
224
|
+
for (const starExportedExternalModule of starExportedExternalModules) {
|
|
225
|
+
if (starExportedExternalModule.externalModulePath !== undefined) {
|
|
226
|
+
this._starExportedExternalModulePaths.push(starExportedExternalModule.externalModulePath);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
Sort.sortBy(this._entities, (x) => x.getSortKey());
|
|
230
|
+
Sort.sortSet(this._dtsTypeReferenceDirectives);
|
|
231
|
+
Sort.sortSet(this._dtsLibReferenceDirectives);
|
|
232
|
+
this._starExportedExternalModulePaths.sort();
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* For a given ts.Identifier that is part of an AstSymbol that we analyzed, return the CollectorEntity that
|
|
236
|
+
* it refers to. Returns undefined if it doesn't refer to anything interesting.
|
|
237
|
+
* @remarks
|
|
238
|
+
* Throws an Error if the ts.Identifier is not part of node tree that was analyzed.
|
|
239
|
+
*/
|
|
240
|
+
tryGetEntityForNode(identifier) {
|
|
241
|
+
const astEntity = this.astSymbolTable.tryGetEntityForNode(identifier);
|
|
242
|
+
if (astEntity) {
|
|
243
|
+
return this._entitiesByAstEntity.get(astEntity);
|
|
244
|
+
}
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* For a given analyzed ts.Symbol, return the CollectorEntity that it refers to. Returns undefined if it
|
|
249
|
+
* doesn't refer to anything interesting.
|
|
250
|
+
*/
|
|
251
|
+
tryGetEntityForSymbol(symbol) {
|
|
252
|
+
return this._entitiesBySymbol.get(symbol);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Returns the associated `CollectorEntity` for the given `astEntity`, if one was created during analysis.
|
|
256
|
+
*/
|
|
257
|
+
tryGetCollectorEntity(astEntity) {
|
|
258
|
+
return this._entitiesByAstEntity.get(astEntity);
|
|
259
|
+
}
|
|
260
|
+
fetchSymbolMetadata(astSymbol) {
|
|
261
|
+
if (astSymbol.symbolMetadata === undefined) {
|
|
262
|
+
this._fetchSymbolMetadata(astSymbol);
|
|
263
|
+
}
|
|
264
|
+
return astSymbol.symbolMetadata;
|
|
265
|
+
}
|
|
266
|
+
fetchDeclarationMetadata(astDeclaration) {
|
|
267
|
+
if (astDeclaration.declarationMetadata === undefined) {
|
|
268
|
+
// Fetching the SymbolMetadata always constructs the DeclarationMetadata
|
|
269
|
+
this._fetchSymbolMetadata(astDeclaration.astSymbol);
|
|
270
|
+
}
|
|
271
|
+
return astDeclaration.declarationMetadata;
|
|
272
|
+
}
|
|
273
|
+
fetchApiItemMetadata(astDeclaration) {
|
|
274
|
+
if (astDeclaration.apiItemMetadata === undefined) {
|
|
275
|
+
// Fetching the SymbolMetadata always constructs the ApiItemMetadata
|
|
276
|
+
this._fetchSymbolMetadata(astDeclaration.astSymbol);
|
|
277
|
+
}
|
|
278
|
+
return astDeclaration.apiItemMetadata;
|
|
279
|
+
}
|
|
280
|
+
tryFetchMetadataForAstEntity(astEntity) {
|
|
281
|
+
if (astEntity instanceof AstSymbol) {
|
|
282
|
+
return this.fetchSymbolMetadata(astEntity);
|
|
283
|
+
}
|
|
284
|
+
if (astEntity instanceof AstImport) {
|
|
285
|
+
if (astEntity.astSymbol) {
|
|
286
|
+
return this.fetchSymbolMetadata(astEntity.astSymbol);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
isAncillaryDeclaration(astDeclaration) {
|
|
292
|
+
const declarationMetadata = this.fetchDeclarationMetadata(astDeclaration);
|
|
293
|
+
return declarationMetadata.isAncillary;
|
|
294
|
+
}
|
|
295
|
+
getNonAncillaryDeclarations(astSymbol) {
|
|
296
|
+
const result = [];
|
|
297
|
+
for (const astDeclaration of astSymbol.astDeclarations) {
|
|
298
|
+
const declarationMetadata = this.fetchDeclarationMetadata(astDeclaration);
|
|
299
|
+
if (!declarationMetadata.isAncillary) {
|
|
300
|
+
result.push(astDeclaration);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Removes the leading underscore, for example: "_Example" --> "example*Example*_"
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* This causes internal definitions to sort alphabetically case-insensitive, then case-sensitive, and
|
|
310
|
+
* initially ignoring the underscore prefix, while still deterministically comparing it.
|
|
311
|
+
* The star is used as a delimiter because it is not a legal identifier character.
|
|
312
|
+
*/
|
|
313
|
+
static getSortKeyIgnoringUnderscore(identifier) {
|
|
314
|
+
if (!identifier)
|
|
315
|
+
return '';
|
|
316
|
+
let parts;
|
|
317
|
+
if (identifier[0] === '_') {
|
|
318
|
+
const withoutUnderscore = identifier.substr(1);
|
|
319
|
+
parts = [withoutUnderscore.toLowerCase(), '*', withoutUnderscore, '*', '_'];
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
parts = [identifier.toLowerCase(), '*', identifier];
|
|
323
|
+
}
|
|
324
|
+
return parts.join('');
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* For function-like signatures, this returns the TSDoc "overload index" which can be used to identify
|
|
328
|
+
* a specific overload.
|
|
329
|
+
*/
|
|
330
|
+
getOverloadIndex(astDeclaration) {
|
|
331
|
+
const allDeclarations = astDeclaration.astSymbol.astDeclarations;
|
|
332
|
+
if (allDeclarations.length === 1) {
|
|
333
|
+
return 1; // trivial case
|
|
334
|
+
}
|
|
335
|
+
let overloadIndex = this._cachedOverloadIndexesByDeclaration.get(astDeclaration);
|
|
336
|
+
if (overloadIndex === undefined) {
|
|
337
|
+
// TSDoc index selectors are positive integers counting from 1
|
|
338
|
+
let nextIndex = 1;
|
|
339
|
+
for (const other of allDeclarations) {
|
|
340
|
+
// Filter out other declarations that are not overloads. For example, an overloaded function can also
|
|
341
|
+
// be a namespace.
|
|
342
|
+
if (other.declaration.kind === astDeclaration.declaration.kind) {
|
|
343
|
+
this._cachedOverloadIndexesByDeclaration.set(other, nextIndex);
|
|
344
|
+
++nextIndex;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
overloadIndex = this._cachedOverloadIndexesByDeclaration.get(astDeclaration);
|
|
348
|
+
}
|
|
349
|
+
if (overloadIndex === undefined) {
|
|
350
|
+
// This should never happen
|
|
351
|
+
throw new InternalError('Error calculating overload index for declaration');
|
|
352
|
+
}
|
|
353
|
+
return overloadIndex;
|
|
354
|
+
}
|
|
355
|
+
_createCollectorEntity(astEntity, exportName, parent) {
|
|
356
|
+
let entity = this._entitiesByAstEntity.get(astEntity);
|
|
357
|
+
if (!entity) {
|
|
358
|
+
entity = new CollectorEntity(astEntity);
|
|
359
|
+
this._entitiesByAstEntity.set(astEntity, entity);
|
|
360
|
+
if (astEntity instanceof AstSymbol) {
|
|
361
|
+
this._entitiesBySymbol.set(astEntity.followedSymbol, entity);
|
|
362
|
+
}
|
|
363
|
+
else if (astEntity instanceof AstNamespaceImport) {
|
|
364
|
+
this._entitiesBySymbol.set(astEntity.symbol, entity);
|
|
365
|
+
}
|
|
366
|
+
this._entities.push(entity);
|
|
367
|
+
this._collectReferenceDirectives(astEntity);
|
|
368
|
+
}
|
|
369
|
+
if (exportName) {
|
|
370
|
+
if (parent) {
|
|
371
|
+
entity.addLocalExportName(exportName, parent);
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
entity.addExportName(exportName);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return entity;
|
|
378
|
+
}
|
|
379
|
+
_recursivelyCreateEntities(astEntity, alreadySeenAstEntities) {
|
|
380
|
+
if (alreadySeenAstEntities.has(astEntity))
|
|
381
|
+
return;
|
|
382
|
+
alreadySeenAstEntities.add(astEntity);
|
|
383
|
+
if (astEntity instanceof AstSymbol) {
|
|
384
|
+
astEntity.forEachDeclarationRecursive((astDeclaration) => {
|
|
385
|
+
for (const referencedAstEntity of astDeclaration.referencedAstEntities) {
|
|
386
|
+
if (referencedAstEntity instanceof AstSymbol) {
|
|
387
|
+
// We only create collector entities for root-level symbols. For example, if a symbol is
|
|
388
|
+
// nested inside a namespace, only the namespace gets a collector entity. Note that this
|
|
389
|
+
// is not true for AstNamespaceImports below.
|
|
390
|
+
if (referencedAstEntity.parentAstSymbol === undefined) {
|
|
391
|
+
this._createCollectorEntity(referencedAstEntity);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
this._createCollectorEntity(referencedAstEntity);
|
|
396
|
+
}
|
|
397
|
+
this._recursivelyCreateEntities(referencedAstEntity, alreadySeenAstEntities);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
if (astEntity instanceof AstNamespaceImport) {
|
|
402
|
+
const astModuleExportInfo = astEntity.fetchAstModuleExportInfo(this);
|
|
403
|
+
const parentEntity = this._entitiesByAstEntity.get(astEntity);
|
|
404
|
+
if (!parentEntity) {
|
|
405
|
+
// This should never happen, as we've already created entities for all AstNamespaceImports.
|
|
406
|
+
throw new InternalError(`Failed to get CollectorEntity for AstNamespaceImport with namespace name "${astEntity.namespaceName}"`);
|
|
407
|
+
}
|
|
408
|
+
for (const [localExportName, localAstEntity] of astModuleExportInfo.exportedLocalEntities) {
|
|
409
|
+
// Create a CollectorEntity for each local export within an AstNamespaceImport entity.
|
|
410
|
+
this._createCollectorEntity(localAstEntity, localExportName, parentEntity);
|
|
411
|
+
this._recursivelyCreateEntities(localAstEntity, alreadySeenAstEntities);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Ensures a unique name for each item in the package typings file.
|
|
417
|
+
*/
|
|
418
|
+
_makeUniqueNames() {
|
|
419
|
+
// The following examples illustrate the nameForEmit heuristics:
|
|
420
|
+
//
|
|
421
|
+
// Example 1:
|
|
422
|
+
// class X { } <--- nameForEmit should be "A" to simplify things and reduce possibility of conflicts
|
|
423
|
+
// export { X as A };
|
|
424
|
+
//
|
|
425
|
+
// Example 2:
|
|
426
|
+
// class X { } <--- nameForEmit should be "X" because choosing A or B would be nondeterministic
|
|
427
|
+
// export { X as A };
|
|
428
|
+
// export { X as B };
|
|
429
|
+
//
|
|
430
|
+
// Example 3:
|
|
431
|
+
// class X { } <--- nameForEmit should be "X_1" because Y has a stronger claim to the name
|
|
432
|
+
// export { X as A };
|
|
433
|
+
// export { X as B };
|
|
434
|
+
// class Y { } <--- nameForEmit should be "X"
|
|
435
|
+
// export { Y as X };
|
|
436
|
+
// Set of names that should NOT be used when generating a unique nameForEmit
|
|
437
|
+
const usedNames = new Set();
|
|
438
|
+
// First collect the names of explicit package exports, and perform a sanity check.
|
|
439
|
+
for (const entity of this._entities) {
|
|
440
|
+
for (const exportName of entity.exportNames) {
|
|
441
|
+
if (usedNames.has(exportName)) {
|
|
442
|
+
// This should be impossible
|
|
443
|
+
throw new InternalError(`A package cannot have two exports with the name "${exportName}"`);
|
|
444
|
+
}
|
|
445
|
+
usedNames.add(exportName);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
// Ensure that each entity has a unique nameForEmit
|
|
449
|
+
for (const entity of this._entities) {
|
|
450
|
+
// What name would we ideally want to emit it as?
|
|
451
|
+
let idealNameForEmit;
|
|
452
|
+
// If this entity is exported exactly once, then we prefer the exported name
|
|
453
|
+
if (entity.singleExportName !== undefined &&
|
|
454
|
+
entity.singleExportName !== ts.InternalSymbolName.Default) {
|
|
455
|
+
idealNameForEmit = entity.singleExportName;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
// otherwise use the local name
|
|
459
|
+
idealNameForEmit = entity.astEntity.localName;
|
|
460
|
+
}
|
|
461
|
+
if (idealNameForEmit.includes('.')) {
|
|
462
|
+
// For an ImportType with a namespace chain, only the top namespace is imported.
|
|
463
|
+
idealNameForEmit = idealNameForEmit.split('.')[0];
|
|
464
|
+
}
|
|
465
|
+
// If the idealNameForEmit happens to be the same as one of the exports, then we're safe to use that...
|
|
466
|
+
if (entity.exportNames.has(idealNameForEmit)) {
|
|
467
|
+
// ...except that if it conflicts with a global name, then the global name wins
|
|
468
|
+
if (!this.globalVariableAnalyzer.hasGlobalName(idealNameForEmit)) {
|
|
469
|
+
// ...also avoid "default" which can interfere with "export { default } from 'some-module;'"
|
|
470
|
+
if (idealNameForEmit !== 'default') {
|
|
471
|
+
entity.nameForEmit = idealNameForEmit;
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
// Generate a unique name based on idealNameForEmit
|
|
477
|
+
let suffix = 1;
|
|
478
|
+
let nameForEmit = idealNameForEmit;
|
|
479
|
+
// Choose a name that doesn't conflict with usedNames or a global name
|
|
480
|
+
while (nameForEmit === 'default' ||
|
|
481
|
+
usedNames.has(nameForEmit) ||
|
|
482
|
+
this.globalVariableAnalyzer.hasGlobalName(nameForEmit)) {
|
|
483
|
+
nameForEmit = `${idealNameForEmit}_${++suffix}`;
|
|
484
|
+
}
|
|
485
|
+
entity.nameForEmit = nameForEmit;
|
|
486
|
+
usedNames.add(nameForEmit);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
_fetchSymbolMetadata(astSymbol) {
|
|
490
|
+
if (astSymbol.symbolMetadata) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
// When we solve an astSymbol, then we always also solve all of its parents and all of its declarations.
|
|
494
|
+
// The parent is solved first.
|
|
495
|
+
if (astSymbol.parentAstSymbol && astSymbol.parentAstSymbol.symbolMetadata === undefined) {
|
|
496
|
+
this._fetchSymbolMetadata(astSymbol.parentAstSymbol);
|
|
497
|
+
}
|
|
498
|
+
// Construct the DeclarationMetadata objects, and detect any ancillary declarations
|
|
499
|
+
this._calculateDeclarationMetadataForDeclarations(astSymbol);
|
|
500
|
+
// Calculate the ApiItemMetadata objects
|
|
501
|
+
for (const astDeclaration of astSymbol.astDeclarations) {
|
|
502
|
+
this._calculateApiItemMetadata(astDeclaration);
|
|
503
|
+
}
|
|
504
|
+
// The most public effectiveReleaseTag for all declarations
|
|
505
|
+
let maxEffectiveReleaseTag = ReleaseTag.None;
|
|
506
|
+
for (const astDeclaration of astSymbol.astDeclarations) {
|
|
507
|
+
// We know we solved this above
|
|
508
|
+
const apiItemMetadata = astDeclaration.apiItemMetadata;
|
|
509
|
+
const effectiveReleaseTag = apiItemMetadata.effectiveReleaseTag;
|
|
510
|
+
if (effectiveReleaseTag > maxEffectiveReleaseTag) {
|
|
511
|
+
maxEffectiveReleaseTag = effectiveReleaseTag;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
// Update this last when we're sure no exceptions were thrown
|
|
515
|
+
astSymbol.symbolMetadata = new SymbolMetadata({
|
|
516
|
+
maxEffectiveReleaseTag
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
_calculateDeclarationMetadataForDeclarations(astSymbol) {
|
|
520
|
+
// Initialize DeclarationMetadata for each declaration
|
|
521
|
+
for (const astDeclaration of astSymbol.astDeclarations) {
|
|
522
|
+
if (astDeclaration.declarationMetadata) {
|
|
523
|
+
throw new InternalError('AstDeclaration.declarationMetadata is not expected to have been initialized yet');
|
|
524
|
+
}
|
|
525
|
+
const metadata = new InternalDeclarationMetadata();
|
|
526
|
+
metadata.tsdocParserContext = this._parseTsdocForAstDeclaration(astDeclaration);
|
|
527
|
+
astDeclaration.declarationMetadata = metadata;
|
|
528
|
+
}
|
|
529
|
+
// Detect ancillary declarations
|
|
530
|
+
for (const astDeclaration of astSymbol.astDeclarations) {
|
|
531
|
+
// For a getter/setter pair, make the setter ancillary to the getter
|
|
532
|
+
if (astDeclaration.declaration.kind === ts.SyntaxKind.SetAccessor) {
|
|
533
|
+
let foundGetter = false;
|
|
534
|
+
for (const getterAstDeclaration of astDeclaration.astSymbol.astDeclarations) {
|
|
535
|
+
if (getterAstDeclaration.declaration.kind === ts.SyntaxKind.GetAccessor) {
|
|
536
|
+
// Associate it with the getter
|
|
537
|
+
this._addAncillaryDeclaration(getterAstDeclaration, astDeclaration);
|
|
538
|
+
foundGetter = true;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (!foundGetter) {
|
|
542
|
+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.MissingGetter, `The property "${astDeclaration.astSymbol.localName}" has a setter but no getter.`, astDeclaration);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
_addAncillaryDeclaration(mainAstDeclaration, ancillaryAstDeclaration) {
|
|
548
|
+
const mainMetadata = mainAstDeclaration.declarationMetadata;
|
|
549
|
+
const ancillaryMetadata = ancillaryAstDeclaration.declarationMetadata;
|
|
550
|
+
if (mainMetadata.ancillaryDeclarations.indexOf(ancillaryAstDeclaration) >= 0) {
|
|
551
|
+
return; // already added
|
|
552
|
+
}
|
|
553
|
+
if (mainAstDeclaration.astSymbol !== ancillaryAstDeclaration.astSymbol) {
|
|
554
|
+
throw new InternalError('Invalid call to _addAncillaryDeclaration() because declarations do not' +
|
|
555
|
+
' belong to the same symbol');
|
|
556
|
+
}
|
|
557
|
+
if (mainMetadata.isAncillary) {
|
|
558
|
+
throw new InternalError('Invalid call to _addAncillaryDeclaration() because the target is ancillary itself');
|
|
559
|
+
}
|
|
560
|
+
if (ancillaryMetadata.isAncillary) {
|
|
561
|
+
throw new InternalError('Invalid call to _addAncillaryDeclaration() because source is already ancillary' +
|
|
562
|
+
' to another declaration');
|
|
563
|
+
}
|
|
564
|
+
if (mainAstDeclaration.apiItemMetadata || ancillaryAstDeclaration.apiItemMetadata) {
|
|
565
|
+
throw new InternalError('Invalid call to _addAncillaryDeclaration() because the API item metadata' +
|
|
566
|
+
' has already been constructed');
|
|
567
|
+
}
|
|
568
|
+
ancillaryMetadata.isAncillary = true;
|
|
569
|
+
mainMetadata.ancillaryDeclarations.push(ancillaryAstDeclaration);
|
|
570
|
+
}
|
|
571
|
+
_calculateApiItemMetadata(astDeclaration) {
|
|
572
|
+
const declarationMetadata = astDeclaration.declarationMetadata;
|
|
573
|
+
if (declarationMetadata.isAncillary) {
|
|
574
|
+
if (astDeclaration.declaration.kind === ts.SyntaxKind.SetAccessor) {
|
|
575
|
+
if (declarationMetadata.tsdocParserContext) {
|
|
576
|
+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.SetterWithDocs, `The doc comment for the property "${astDeclaration.astSymbol.localName}"` +
|
|
577
|
+
` must appear on the getter, not the setter.`, astDeclaration);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
// We never calculate ApiItemMetadata for an ancillary declaration; instead, it is assigned when
|
|
581
|
+
// the main declaration is processed.
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const options = {
|
|
585
|
+
declaredReleaseTag: ReleaseTag.None,
|
|
586
|
+
effectiveReleaseTag: ReleaseTag.None,
|
|
587
|
+
isEventProperty: false,
|
|
588
|
+
isOverride: false,
|
|
589
|
+
isSealed: false,
|
|
590
|
+
isVirtual: false,
|
|
591
|
+
isPreapproved: false,
|
|
592
|
+
releaseTagSameAsParent: false
|
|
593
|
+
};
|
|
594
|
+
const parserContext = declarationMetadata.tsdocParserContext;
|
|
595
|
+
if (parserContext) {
|
|
596
|
+
const modifierTagSet = parserContext.docComment.modifierTagSet;
|
|
597
|
+
let declaredReleaseTag = ReleaseTag.None;
|
|
598
|
+
let extraReleaseTags = false;
|
|
599
|
+
if (modifierTagSet.isPublic()) {
|
|
600
|
+
declaredReleaseTag = ReleaseTag.Public;
|
|
601
|
+
}
|
|
602
|
+
if (modifierTagSet.isBeta()) {
|
|
603
|
+
if (declaredReleaseTag !== ReleaseTag.None) {
|
|
604
|
+
extraReleaseTags = true;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
declaredReleaseTag = ReleaseTag.Beta;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (modifierTagSet.isAlpha()) {
|
|
611
|
+
if (declaredReleaseTag !== ReleaseTag.None) {
|
|
612
|
+
extraReleaseTags = true;
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
declaredReleaseTag = ReleaseTag.Alpha;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (modifierTagSet.isInternal()) {
|
|
619
|
+
if (declaredReleaseTag !== ReleaseTag.None) {
|
|
620
|
+
extraReleaseTags = true;
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
declaredReleaseTag = ReleaseTag.Internal;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (extraReleaseTags) {
|
|
627
|
+
if (!astDeclaration.astSymbol.isExternal) {
|
|
628
|
+
// for now, don't report errors for external code
|
|
629
|
+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.ExtraReleaseTag, 'The doc comment should not contain more than one release tag', astDeclaration);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
options.declaredReleaseTag = declaredReleaseTag;
|
|
633
|
+
options.isEventProperty = modifierTagSet.isEventProperty();
|
|
634
|
+
options.isOverride = modifierTagSet.isOverride();
|
|
635
|
+
options.isSealed = modifierTagSet.isSealed();
|
|
636
|
+
options.isVirtual = modifierTagSet.isVirtual();
|
|
637
|
+
const preapprovedTag = this.extractorConfig.tsdocConfiguration.tryGetTagDefinition('@preapproved');
|
|
638
|
+
if (preapprovedTag && modifierTagSet.hasTag(preapprovedTag)) {
|
|
639
|
+
// This feature only makes sense for potentially big declarations.
|
|
640
|
+
switch (astDeclaration.declaration.kind) {
|
|
641
|
+
case ts.SyntaxKind.ClassDeclaration:
|
|
642
|
+
case ts.SyntaxKind.EnumDeclaration:
|
|
643
|
+
case ts.SyntaxKind.InterfaceDeclaration:
|
|
644
|
+
case ts.SyntaxKind.ModuleDeclaration:
|
|
645
|
+
if (declaredReleaseTag === ReleaseTag.Internal) {
|
|
646
|
+
options.isPreapproved = true;
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.PreapprovedBadReleaseTag, `The @preapproved tag cannot be applied to "${astDeclaration.astSymbol.localName}"` +
|
|
650
|
+
` without an @internal release tag`, astDeclaration);
|
|
651
|
+
}
|
|
652
|
+
break;
|
|
653
|
+
default:
|
|
654
|
+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.PreapprovedUnsupportedType, `The @preapproved tag cannot be applied to "${astDeclaration.astSymbol.localName}"` +
|
|
655
|
+
` because it is not a supported declaration type`, astDeclaration);
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
// This needs to be set regardless of whether or not a parserContext exists
|
|
661
|
+
if (astDeclaration.parent) {
|
|
662
|
+
const parentApiItemMetadata = this.fetchApiItemMetadata(astDeclaration.parent);
|
|
663
|
+
options.effectiveReleaseTag =
|
|
664
|
+
options.declaredReleaseTag === ReleaseTag.None
|
|
665
|
+
? parentApiItemMetadata.effectiveReleaseTag
|
|
666
|
+
: options.declaredReleaseTag;
|
|
667
|
+
options.releaseTagSameAsParent =
|
|
668
|
+
parentApiItemMetadata.effectiveReleaseTag === options.effectiveReleaseTag;
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
options.effectiveReleaseTag = options.declaredReleaseTag;
|
|
672
|
+
}
|
|
673
|
+
if (options.effectiveReleaseTag === ReleaseTag.None) {
|
|
674
|
+
if (!astDeclaration.astSymbol.isExternal) {
|
|
675
|
+
// for now, don't report errors for external code
|
|
676
|
+
// Don't report missing release tags for forgotten exports (unless we're including forgotten exports
|
|
677
|
+
// in either the API report or doc model).
|
|
678
|
+
const astSymbol = astDeclaration.astSymbol;
|
|
679
|
+
const entity = this._entitiesByAstEntity.get(astSymbol.rootAstSymbol);
|
|
680
|
+
if (entity &&
|
|
681
|
+
(entity.consumable ||
|
|
682
|
+
this.extractorConfig.apiReportIncludeForgottenExports ||
|
|
683
|
+
this.extractorConfig.docModelIncludeForgottenExports)) {
|
|
684
|
+
// We also don't report errors for the default export of an entry point, since its doc comment
|
|
685
|
+
// isn't easy to obtain from the .d.ts file
|
|
686
|
+
if (astSymbol.rootAstSymbol.localName !== '_default') {
|
|
687
|
+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.MissingReleaseTag, `"${entity.astEntity.localName}" is part of the package's API, but it is missing ` +
|
|
688
|
+
`a release tag (@alpha, @beta, @public, or @internal)`, astSymbol);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
options.effectiveReleaseTag = ReleaseTag.Public;
|
|
693
|
+
}
|
|
694
|
+
const apiItemMetadata = new ApiItemMetadata(options);
|
|
695
|
+
if (parserContext) {
|
|
696
|
+
apiItemMetadata.tsdocComment = parserContext.docComment;
|
|
697
|
+
}
|
|
698
|
+
astDeclaration.apiItemMetadata = apiItemMetadata;
|
|
699
|
+
// Lastly, share the result with any ancillary declarations
|
|
700
|
+
for (const ancillaryDeclaration of declarationMetadata.ancillaryDeclarations) {
|
|
701
|
+
ancillaryDeclaration.apiItemMetadata = apiItemMetadata;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
_parseTsdocForAstDeclaration(astDeclaration) {
|
|
705
|
+
const declaration = astDeclaration.declaration;
|
|
706
|
+
let nodeForComment = declaration;
|
|
707
|
+
if (ts.isVariableDeclaration(declaration)) {
|
|
708
|
+
// Variable declarations are special because they can be combined into a list. For example:
|
|
709
|
+
//
|
|
710
|
+
// /** A */ export /** B */ const /** C */ x = 1, /** D **/ [ /** E */ y, z] = [3, 4];
|
|
711
|
+
//
|
|
712
|
+
// The compiler will only emit comments A and C in the .d.ts file, so in general there isn't a well-defined
|
|
713
|
+
// way to document these parts. API Extractor requires you to break them into separate exports like this:
|
|
714
|
+
//
|
|
715
|
+
// /** A */ export const x = 1;
|
|
716
|
+
//
|
|
717
|
+
// But _getReleaseTagForDeclaration() still receives a node corresponding to "x", so we need to walk upwards
|
|
718
|
+
// and find the containing statement in order for getJSDocCommentRanges() to read the comment that we expect.
|
|
719
|
+
const statement = TypeScriptHelpers.findFirstParent(declaration, ts.SyntaxKind.VariableStatement);
|
|
720
|
+
if (statement !== undefined) {
|
|
721
|
+
// For a compound declaration, fall back to looking for C instead of A
|
|
722
|
+
if (statement.declarationList.declarations.length === 1) {
|
|
723
|
+
nodeForComment = statement;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
const sourceFileText = declaration.getSourceFile().text;
|
|
728
|
+
const ranges = TypeScriptInternals.getJSDocCommentRanges(nodeForComment, sourceFileText) || [];
|
|
729
|
+
if (ranges.length === 0) {
|
|
730
|
+
return undefined;
|
|
731
|
+
}
|
|
732
|
+
// We use the JSDoc comment block that is closest to the definition, i.e.
|
|
733
|
+
// the last one preceding it
|
|
734
|
+
const range = ranges[ranges.length - 1];
|
|
735
|
+
const tsdocTextRange = tsdoc.TextRange.fromStringRange(sourceFileText, range.pos, range.end);
|
|
736
|
+
const parserContext = this._tsdocParser.parseRange(tsdocTextRange);
|
|
737
|
+
this.messageRouter.addTsdocMessages(parserContext, declaration.getSourceFile(), astDeclaration);
|
|
738
|
+
// We delete the @privateRemarks block as early as possible, to ensure that it never leaks through
|
|
739
|
+
// into one of the output files.
|
|
740
|
+
parserContext.docComment.privateRemarks = undefined;
|
|
741
|
+
return parserContext;
|
|
742
|
+
}
|
|
743
|
+
_collectReferenceDirectives(astEntity) {
|
|
744
|
+
// Here, we're collecting reference directives from source files that contain extracted
|
|
745
|
+
// definitions (i.e. - files that contain `export class ...`, `export interface ...`, ...).
|
|
746
|
+
// These references may or may not include the `preserve="true" attribute. In TS < 5.5,
|
|
747
|
+
// references that end up in .D.TS files may or may not be explicity written by the developer.
|
|
748
|
+
// In TS >= 5.5, only references that are explicitly authored and are marked with
|
|
749
|
+
// `preserve="true"` are included in the output. See https://github.com/microsoft/TypeScript/pull/57681
|
|
750
|
+
//
|
|
751
|
+
// The calls to `_collectReferenceDirectivesFromSourceFiles` in this function are
|
|
752
|
+
// preserving existing behavior, which is to include all reference directives
|
|
753
|
+
// regardless of whether they are explicitly authored or not, but only in files that
|
|
754
|
+
// contain definitions.
|
|
755
|
+
if (astEntity instanceof AstSymbol) {
|
|
756
|
+
const sourceFiles = astEntity.astDeclarations.map((astDeclaration) => astDeclaration.declaration.getSourceFile());
|
|
757
|
+
return this._collectReferenceDirectivesFromSourceFiles(sourceFiles, false);
|
|
758
|
+
}
|
|
759
|
+
if (astEntity instanceof AstNamespaceImport) {
|
|
760
|
+
const sourceFiles = [astEntity.astModule.sourceFile];
|
|
761
|
+
return this._collectReferenceDirectivesFromSourceFiles(sourceFiles, false);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
_collectReferenceDirectivesFromSourceFiles(sourceFiles, onlyIncludeExplicitlyPreserved) {
|
|
765
|
+
const seenFilenames = new Set();
|
|
766
|
+
for (const sourceFile of sourceFiles) {
|
|
767
|
+
if (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName) {
|
|
768
|
+
const { fileName, typeReferenceDirectives, libReferenceDirectives, text: sourceFileText } = sourceFile;
|
|
769
|
+
if (!seenFilenames.has(fileName)) {
|
|
770
|
+
seenFilenames.add(fileName);
|
|
771
|
+
for (const typeReferenceDirective of typeReferenceDirectives) {
|
|
772
|
+
const name = this._getReferenceDirectiveFromSourceFile(sourceFileText, typeReferenceDirective, onlyIncludeExplicitlyPreserved);
|
|
773
|
+
if (name) {
|
|
774
|
+
this._dtsTypeReferenceDirectives.add(name);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
for (const libReferenceDirective of libReferenceDirectives) {
|
|
778
|
+
const reference = this._getReferenceDirectiveFromSourceFile(sourceFileText, libReferenceDirective, onlyIncludeExplicitlyPreserved);
|
|
779
|
+
if (reference) {
|
|
780
|
+
this._dtsLibReferenceDirectives.add(reference);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
_getReferenceDirectiveFromSourceFile(sourceFileText, { pos, end, preserve }, onlyIncludeExplicitlyPreserved) {
|
|
788
|
+
const reference = sourceFileText.substring(pos, end);
|
|
789
|
+
if (preserve || !onlyIncludeExplicitlyPreserved) {
|
|
790
|
+
return reference;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
//# sourceMappingURL=Collector.js.map
|