@microsoft/api-extractor 7.56.3 → 7.57.1
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 +58 -0
- package/CHANGELOG.md +15 -1
- package/bin/api-extractor +1 -1
- package/dist/tsdoc-metadata.json +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 +37 -9
- /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,57 @@
|
|
|
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 { AstSyntheticEntity } from './AstEntity';
|
|
4
|
+
/**
|
|
5
|
+
* `AstNamespaceImport` represents a namespace that is created implicitly by a statement
|
|
6
|
+
* such as `import * as example from "./file";`
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
*
|
|
10
|
+
* A typical input looks like this:
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Suppose that example.ts exports two functions f1() and f2().
|
|
13
|
+
* import * as example from "./file";
|
|
14
|
+
* export { example };
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* API Extractor's .d.ts rollup will transform it into an explicit namespace, like this:
|
|
18
|
+
* ```ts
|
|
19
|
+
* declare f1(): void;
|
|
20
|
+
* declare f2(): void;
|
|
21
|
+
*
|
|
22
|
+
* declare namespace example {
|
|
23
|
+
* export {
|
|
24
|
+
* f1,
|
|
25
|
+
* f2
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The current implementation does not attempt to relocate f1()/f2() to be inside the `namespace`
|
|
31
|
+
* because other type signatures may reference them directly (without using the namespace qualifier).
|
|
32
|
+
* The `declare namespace example` is a synthetic construct represented by `AstNamespaceImport`.
|
|
33
|
+
*/
|
|
34
|
+
export class AstNamespaceImport extends AstSyntheticEntity {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super();
|
|
37
|
+
/**
|
|
38
|
+
* Returns true if the AstSymbolTable.analyze() was called for this object.
|
|
39
|
+
* See that function for details.
|
|
40
|
+
*/
|
|
41
|
+
this.analyzed = false;
|
|
42
|
+
this.astModule = options.astModule;
|
|
43
|
+
this.namespaceName = options.namespaceName;
|
|
44
|
+
this.declaration = options.declaration;
|
|
45
|
+
this.symbol = options.symbol;
|
|
46
|
+
}
|
|
47
|
+
/** {@inheritdoc} */
|
|
48
|
+
get localName() {
|
|
49
|
+
// abstract
|
|
50
|
+
return this.namespaceName;
|
|
51
|
+
}
|
|
52
|
+
fetchAstModuleExportInfo(collector) {
|
|
53
|
+
const astModuleExportInfo = collector.astSymbolTable.fetchAstModuleExportInfo(this.astModule);
|
|
54
|
+
return astModuleExportInfo;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=AstNamespaceImport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AstNamespaceImport.js","sourceRoot":"","sources":["../../src/analyzer/AstNamespaceImport.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAK3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAUjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IA6BxD,YAAmB,OAAmC;QACpD,KAAK,EAAE,CAAC;QA7BV;;;WAGG;QACI,aAAQ,GAAY,KAAK,CAAC;QA0B/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,oBAAoB;IACpB,IAAW,SAAS;QAClB,WAAW;QACX,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEM,wBAAwB,CAAC,SAAoB;QAClD,MAAM,mBAAmB,GAAyB,SAAS,CAAC,cAAc,CAAC,wBAAwB,CACjG,IAAI,CAAC,SAAS,CACf,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport type { AstModule, IAstModuleExportInfo } from './AstModule';\nimport { AstSyntheticEntity } from './AstEntity';\nimport type { Collector } from '../collector/Collector';\n\nexport interface IAstNamespaceImportOptions {\n readonly astModule: AstModule;\n readonly namespaceName: string;\n readonly declaration: ts.Declaration;\n readonly symbol: ts.Symbol;\n}\n\n/**\n * `AstNamespaceImport` represents a namespace that is created implicitly by a statement\n * such as `import * as example from \"./file\";`\n *\n * @remarks\n *\n * A typical input looks like this:\n * ```ts\n * // Suppose that example.ts exports two functions f1() and f2().\n * import * as example from \"./file\";\n * export { example };\n * ```\n *\n * API Extractor's .d.ts rollup will transform it into an explicit namespace, like this:\n * ```ts\n * declare f1(): void;\n * declare f2(): void;\n *\n * declare namespace example {\n * export {\n * f1,\n * f2\n * }\n * }\n * ```\n *\n * The current implementation does not attempt to relocate f1()/f2() to be inside the `namespace`\n * because other type signatures may reference them directly (without using the namespace qualifier).\n * The `declare namespace example` is a synthetic construct represented by `AstNamespaceImport`.\n */\nexport class AstNamespaceImport extends AstSyntheticEntity {\n /**\n * Returns true if the AstSymbolTable.analyze() was called for this object.\n * See that function for details.\n */\n public analyzed: boolean = false;\n\n /**\n * For example, if the original statement was `import * as example from \"./file\";`\n * then `astModule` refers to the `./file.d.ts` file.\n */\n public readonly astModule: AstModule;\n\n /**\n * For example, if the original statement was `import * as example from \"./file\";`\n * then `namespaceName` would be `example`.\n */\n public readonly namespaceName: string;\n\n /**\n * The original `ts.SyntaxKind.NamespaceImport` which can be used as a location for error messages.\n */\n public readonly declaration: ts.Declaration;\n\n /**\n * The original `ts.SymbolFlags.Namespace` symbol.\n */\n public readonly symbol: ts.Symbol;\n\n public constructor(options: IAstNamespaceImportOptions) {\n super();\n this.astModule = options.astModule;\n this.namespaceName = options.namespaceName;\n this.declaration = options.declaration;\n this.symbol = options.symbol;\n }\n\n /** {@inheritdoc} */\n public get localName(): string {\n // abstract\n return this.namespaceName;\n }\n\n public fetchAstModuleExportInfo(collector: Collector): IAstModuleExportInfo {\n const astModuleExportInfo: IAstModuleExportInfo = collector.astSymbolTable.fetchAstModuleExportInfo(\n this.astModule\n );\n return astModuleExportInfo;\n }\n}\n"]}
|
|
@@ -0,0 +1,202 @@
|
|
|
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 * as tsdoc from '@microsoft/tsdoc';
|
|
5
|
+
import { AstSymbol } from './AstSymbol';
|
|
6
|
+
/**
|
|
7
|
+
* Used by `AstReferenceResolver` to report a failed resolution.
|
|
8
|
+
*
|
|
9
|
+
* @privateRemarks
|
|
10
|
+
* This class is similar to an `Error` object, but the intent of `ResolverFailure` is to describe
|
|
11
|
+
* why a reference could not be resolved. This information could be used to throw an actual `Error` object,
|
|
12
|
+
* but normally it is handed off to the `MessageRouter` instead.
|
|
13
|
+
*/
|
|
14
|
+
export class ResolverFailure {
|
|
15
|
+
constructor(reason) {
|
|
16
|
+
this.reason = reason;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* This resolves a TSDoc declaration reference by walking the `AstSymbolTable` compiler state.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
*
|
|
24
|
+
* This class is analogous to `ModelReferenceResolver` from the `@microsoft/api-extractor-model` project,
|
|
25
|
+
* which resolves declaration references by walking the hierarchy loaded from an .api.json file.
|
|
26
|
+
*/
|
|
27
|
+
export class AstReferenceResolver {
|
|
28
|
+
constructor(collector) {
|
|
29
|
+
this._collector = collector;
|
|
30
|
+
this._astSymbolTable = collector.astSymbolTable;
|
|
31
|
+
this._workingPackage = collector.workingPackage;
|
|
32
|
+
}
|
|
33
|
+
resolve(declarationReference) {
|
|
34
|
+
// Is it referring to the working package?
|
|
35
|
+
if (declarationReference.packageName !== undefined &&
|
|
36
|
+
declarationReference.packageName !== this._workingPackage.name) {
|
|
37
|
+
return new ResolverFailure('External package references are not supported');
|
|
38
|
+
}
|
|
39
|
+
// Is it a path-based import?
|
|
40
|
+
if (declarationReference.importPath) {
|
|
41
|
+
return new ResolverFailure('Import paths are not supported');
|
|
42
|
+
}
|
|
43
|
+
const astModule = this._astSymbolTable.fetchAstModuleFromWorkingPackage(this._workingPackage.entryPointSourceFile);
|
|
44
|
+
if (declarationReference.memberReferences.length === 0) {
|
|
45
|
+
return new ResolverFailure('Package references are not supported');
|
|
46
|
+
}
|
|
47
|
+
const rootMemberReference = declarationReference.memberReferences[0];
|
|
48
|
+
const exportName = this._getMemberReferenceIdentifier(rootMemberReference);
|
|
49
|
+
if (exportName instanceof ResolverFailure) {
|
|
50
|
+
return exportName;
|
|
51
|
+
}
|
|
52
|
+
const rootAstEntity = this._astSymbolTable.tryGetExportOfAstModule(exportName, astModule);
|
|
53
|
+
if (rootAstEntity === undefined) {
|
|
54
|
+
return new ResolverFailure(`The package "${this._workingPackage.name}" does not have an export "${exportName}"`);
|
|
55
|
+
}
|
|
56
|
+
if (!(rootAstEntity instanceof AstSymbol)) {
|
|
57
|
+
return new ResolverFailure('This type of declaration is not supported yet by the resolver');
|
|
58
|
+
}
|
|
59
|
+
let currentDeclaration = this._selectDeclaration(rootAstEntity.astDeclarations, rootMemberReference, rootAstEntity.localName);
|
|
60
|
+
if (currentDeclaration instanceof ResolverFailure) {
|
|
61
|
+
return currentDeclaration;
|
|
62
|
+
}
|
|
63
|
+
for (let index = 1; index < declarationReference.memberReferences.length; ++index) {
|
|
64
|
+
const memberReference = declarationReference.memberReferences[index];
|
|
65
|
+
const memberName = this._getMemberReferenceIdentifier(memberReference);
|
|
66
|
+
if (memberName instanceof ResolverFailure) {
|
|
67
|
+
return memberName;
|
|
68
|
+
}
|
|
69
|
+
const matchingChildren = currentDeclaration.findChildrenWithName(memberName);
|
|
70
|
+
if (matchingChildren.length === 0) {
|
|
71
|
+
return new ResolverFailure(`No member was found with name "${memberName}"`);
|
|
72
|
+
}
|
|
73
|
+
const selectedDeclaration = this._selectDeclaration(matchingChildren, memberReference, memberName);
|
|
74
|
+
if (selectedDeclaration instanceof ResolverFailure) {
|
|
75
|
+
return selectedDeclaration;
|
|
76
|
+
}
|
|
77
|
+
currentDeclaration = selectedDeclaration;
|
|
78
|
+
}
|
|
79
|
+
return currentDeclaration;
|
|
80
|
+
}
|
|
81
|
+
_getMemberReferenceIdentifier(memberReference) {
|
|
82
|
+
if (memberReference.memberSymbol !== undefined) {
|
|
83
|
+
return new ResolverFailure('ECMAScript symbol selectors are not supported');
|
|
84
|
+
}
|
|
85
|
+
if (memberReference.memberIdentifier === undefined) {
|
|
86
|
+
return new ResolverFailure('The member identifier is missing in the root member reference');
|
|
87
|
+
}
|
|
88
|
+
return memberReference.memberIdentifier.identifier;
|
|
89
|
+
}
|
|
90
|
+
_selectDeclaration(astDeclarations, memberReference, astSymbolName) {
|
|
91
|
+
const memberSelector = memberReference.selector;
|
|
92
|
+
if (memberSelector === undefined) {
|
|
93
|
+
if (astDeclarations.length === 1) {
|
|
94
|
+
return astDeclarations[0];
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// If we found multiple matches, but the extra ones are all ancillary declarations,
|
|
98
|
+
// then return the main declaration.
|
|
99
|
+
const nonAncillaryMatch = this._tryDisambiguateAncillaryMatches(astDeclarations);
|
|
100
|
+
if (nonAncillaryMatch) {
|
|
101
|
+
return nonAncillaryMatch;
|
|
102
|
+
}
|
|
103
|
+
return new ResolverFailure(`The reference is ambiguous because "${astSymbolName}"` +
|
|
104
|
+
` has more than one declaration; you need to add a TSDoc member reference selector`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
switch (memberSelector.selectorKind) {
|
|
108
|
+
case tsdoc.SelectorKind.System:
|
|
109
|
+
return this._selectUsingSystemSelector(astDeclarations, memberSelector, astSymbolName);
|
|
110
|
+
case tsdoc.SelectorKind.Index:
|
|
111
|
+
return this._selectUsingIndexSelector(astDeclarations, memberSelector, astSymbolName);
|
|
112
|
+
}
|
|
113
|
+
return new ResolverFailure(`The selector "${memberSelector.selector}" is not a supported selector type`);
|
|
114
|
+
}
|
|
115
|
+
_selectUsingSystemSelector(astDeclarations, memberSelector, astSymbolName) {
|
|
116
|
+
const selectorName = memberSelector.selector;
|
|
117
|
+
let selectorSyntaxKind;
|
|
118
|
+
switch (selectorName) {
|
|
119
|
+
case 'class':
|
|
120
|
+
selectorSyntaxKind = ts.SyntaxKind.ClassDeclaration;
|
|
121
|
+
break;
|
|
122
|
+
case 'enum':
|
|
123
|
+
selectorSyntaxKind = ts.SyntaxKind.EnumDeclaration;
|
|
124
|
+
break;
|
|
125
|
+
case 'function':
|
|
126
|
+
selectorSyntaxKind = ts.SyntaxKind.FunctionDeclaration;
|
|
127
|
+
break;
|
|
128
|
+
case 'interface':
|
|
129
|
+
selectorSyntaxKind = ts.SyntaxKind.InterfaceDeclaration;
|
|
130
|
+
break;
|
|
131
|
+
case 'namespace':
|
|
132
|
+
selectorSyntaxKind = ts.SyntaxKind.ModuleDeclaration;
|
|
133
|
+
break;
|
|
134
|
+
case 'type':
|
|
135
|
+
selectorSyntaxKind = ts.SyntaxKind.TypeAliasDeclaration;
|
|
136
|
+
break;
|
|
137
|
+
case 'variable':
|
|
138
|
+
selectorSyntaxKind = ts.SyntaxKind.VariableDeclaration;
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
return new ResolverFailure(`Unsupported system selector "${selectorName}"`);
|
|
142
|
+
}
|
|
143
|
+
const matches = astDeclarations.filter((x) => x.declaration.kind === selectorSyntaxKind);
|
|
144
|
+
if (matches.length === 0) {
|
|
145
|
+
return new ResolverFailure(`A declaration for "${astSymbolName}" was not found that matches the` +
|
|
146
|
+
` TSDoc selector "${selectorName}"`);
|
|
147
|
+
}
|
|
148
|
+
if (matches.length > 1) {
|
|
149
|
+
// If we found multiple matches, but the extra ones are all ancillary declarations,
|
|
150
|
+
// then return the main declaration.
|
|
151
|
+
const nonAncillaryMatch = this._tryDisambiguateAncillaryMatches(matches);
|
|
152
|
+
if (nonAncillaryMatch) {
|
|
153
|
+
return nonAncillaryMatch;
|
|
154
|
+
}
|
|
155
|
+
return new ResolverFailure(`More than one declaration "${astSymbolName}" matches the TSDoc selector "${selectorName}"`);
|
|
156
|
+
}
|
|
157
|
+
return matches[0];
|
|
158
|
+
}
|
|
159
|
+
_selectUsingIndexSelector(astDeclarations, memberSelector, astSymbolName) {
|
|
160
|
+
const selectorOverloadIndex = parseInt(memberSelector.selector, 10);
|
|
161
|
+
const matches = [];
|
|
162
|
+
for (const astDeclaration of astDeclarations) {
|
|
163
|
+
const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
|
|
164
|
+
if (overloadIndex === selectorOverloadIndex) {
|
|
165
|
+
matches.push(astDeclaration);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (matches.length === 0) {
|
|
169
|
+
return new ResolverFailure(`An overload for "${astSymbolName}" was not found that matches the` +
|
|
170
|
+
` TSDoc selector ":${selectorOverloadIndex}"`);
|
|
171
|
+
}
|
|
172
|
+
if (matches.length > 1) {
|
|
173
|
+
// If we found multiple matches, but the extra ones are all ancillary declarations,
|
|
174
|
+
// then return the main declaration.
|
|
175
|
+
const nonAncillaryMatch = this._tryDisambiguateAncillaryMatches(matches);
|
|
176
|
+
if (nonAncillaryMatch) {
|
|
177
|
+
return nonAncillaryMatch;
|
|
178
|
+
}
|
|
179
|
+
return new ResolverFailure(`More than one declaration for "${astSymbolName}" matches the` +
|
|
180
|
+
` TSDoc selector ":${selectorOverloadIndex}"`);
|
|
181
|
+
}
|
|
182
|
+
return matches[0];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* This resolves an ambiguous match in the case where the extra matches are all ancillary declarations,
|
|
186
|
+
* except for one match that is the main declaration.
|
|
187
|
+
*/
|
|
188
|
+
_tryDisambiguateAncillaryMatches(matches) {
|
|
189
|
+
let result = undefined;
|
|
190
|
+
for (const match of matches) {
|
|
191
|
+
const declarationMetadata = this._collector.fetchDeclarationMetadata(match);
|
|
192
|
+
if (!declarationMetadata.isAncillary) {
|
|
193
|
+
if (result) {
|
|
194
|
+
return undefined; // more than one match
|
|
195
|
+
}
|
|
196
|
+
result = match;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=AstReferenceResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AstReferenceResolver.js","sourceRoot":"","sources":["../../src/analyzer/AstReferenceResolver.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAS1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAM1B,YAAmB,MAAc;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAoB;IAK/B,YAAmB,SAAoB;QACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC;IAClD,CAAC;IAEM,OAAO,CAAC,oBAAmD;QAChE,0CAA0C;QAC1C,IACE,oBAAoB,CAAC,WAAW,KAAK,SAAS;YAC9C,oBAAoB,CAAC,WAAW,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI,EAC9D,CAAC;YACD,OAAO,IAAI,eAAe,CAAC,+CAA+C,CAAC,CAAC;QAC9E,CAA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ACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport * as tsdoc from '@microsoft/tsdoc';\n\nimport type { AstSymbolTable } from './AstSymbolTable';\nimport type { AstEntity } from './AstEntity';\nimport type { AstDeclaration } from './AstDeclaration';\nimport type { WorkingPackage } from '../collector/WorkingPackage';\nimport type { AstModule } from './AstModule';\nimport type { Collector } from '../collector/Collector';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstSymbol } from './AstSymbol';\n\n/**\n * Used by `AstReferenceResolver` to report a failed resolution.\n *\n * @privateRemarks\n * This class is similar to an `Error` object, but the intent of `ResolverFailure` is to describe\n * why a reference could not be resolved. This information could be used to throw an actual `Error` object,\n * but normally it is handed off to the `MessageRouter` instead.\n */\nexport class ResolverFailure {\n /**\n * Details about why the failure occurred.\n */\n public readonly reason: string;\n\n public constructor(reason: string) {\n this.reason = reason;\n }\n}\n\n/**\n * This resolves a TSDoc declaration reference by walking the `AstSymbolTable` compiler state.\n *\n * @remarks\n *\n * This class is analogous to `ModelReferenceResolver` from the `@microsoft/api-extractor-model` project,\n * which resolves declaration references by walking the hierarchy loaded from an .api.json file.\n */\nexport class AstReferenceResolver {\n private readonly _collector: Collector;\n private readonly _astSymbolTable: AstSymbolTable;\n private readonly _workingPackage: WorkingPackage;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n this._astSymbolTable = collector.astSymbolTable;\n this._workingPackage = collector.workingPackage;\n }\n\n public resolve(declarationReference: tsdoc.DocDeclarationReference): AstDeclaration | ResolverFailure {\n // Is it referring to the working package?\n if (\n declarationReference.packageName !== undefined &&\n declarationReference.packageName !== this._workingPackage.name\n ) {\n return new ResolverFailure('External package references are not supported');\n }\n\n // Is it a path-based import?\n if (declarationReference.importPath) {\n return new ResolverFailure('Import paths are not supported');\n }\n\n const astModule: AstModule = this._astSymbolTable.fetchAstModuleFromWorkingPackage(\n this._workingPackage.entryPointSourceFile\n );\n\n if (declarationReference.memberReferences.length === 0) {\n return new ResolverFailure('Package references are not supported');\n }\n\n const rootMemberReference: tsdoc.DocMemberReference = declarationReference.memberReferences[0];\n\n const exportName: string | ResolverFailure = this._getMemberReferenceIdentifier(rootMemberReference);\n if (exportName instanceof ResolverFailure) {\n return exportName;\n }\n\n const rootAstEntity: AstEntity | undefined = this._astSymbolTable.tryGetExportOfAstModule(\n exportName,\n astModule\n );\n\n if (rootAstEntity === undefined) {\n return new ResolverFailure(\n `The package \"${this._workingPackage.name}\" does not have an export \"${exportName}\"`\n );\n }\n\n if (!(rootAstEntity instanceof AstSymbol)) {\n return new ResolverFailure('This type of declaration is not supported yet by the resolver');\n }\n\n let currentDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(\n rootAstEntity.astDeclarations,\n rootMemberReference,\n rootAstEntity.localName\n );\n\n if (currentDeclaration instanceof ResolverFailure) {\n return currentDeclaration;\n }\n\n for (let index: number = 1; index < declarationReference.memberReferences.length; ++index) {\n const memberReference: tsdoc.DocMemberReference = declarationReference.memberReferences[index];\n\n const memberName: string | ResolverFailure = this._getMemberReferenceIdentifier(memberReference);\n if (memberName instanceof ResolverFailure) {\n return memberName;\n }\n\n const matchingChildren: ReadonlyArray<AstDeclaration> =\n currentDeclaration.findChildrenWithName(memberName);\n if (matchingChildren.length === 0) {\n return new ResolverFailure(`No member was found with name \"${memberName}\"`);\n }\n\n const selectedDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(\n matchingChildren,\n memberReference,\n memberName\n );\n\n if (selectedDeclaration instanceof ResolverFailure) {\n return selectedDeclaration;\n }\n\n currentDeclaration = selectedDeclaration;\n }\n\n return currentDeclaration;\n }\n\n private _getMemberReferenceIdentifier(memberReference: tsdoc.DocMemberReference): string | ResolverFailure {\n if (memberReference.memberSymbol !== undefined) {\n return new ResolverFailure('ECMAScript symbol selectors are not supported');\n }\n if (memberReference.memberIdentifier === undefined) {\n return new ResolverFailure('The member identifier is missing in the root member reference');\n }\n return memberReference.memberIdentifier.identifier;\n }\n\n private _selectDeclaration(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberReference: tsdoc.DocMemberReference,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const memberSelector: tsdoc.DocMemberSelector | undefined = memberReference.selector;\n\n if (memberSelector === undefined) {\n if (astDeclarations.length === 1) {\n return astDeclarations[0];\n } else {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined =\n this._tryDisambiguateAncillaryMatches(astDeclarations);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `The reference is ambiguous because \"${astSymbolName}\"` +\n ` has more than one declaration; you need to add a TSDoc member reference selector`\n );\n }\n }\n\n switch (memberSelector.selectorKind) {\n case tsdoc.SelectorKind.System:\n return this._selectUsingSystemSelector(astDeclarations, memberSelector, astSymbolName);\n case tsdoc.SelectorKind.Index:\n return this._selectUsingIndexSelector(astDeclarations, memberSelector, astSymbolName);\n }\n\n return new ResolverFailure(`The selector \"${memberSelector.selector}\" is not a supported selector type`);\n }\n\n private _selectUsingSystemSelector(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberSelector: tsdoc.DocMemberSelector,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const selectorName: string = memberSelector.selector;\n\n let selectorSyntaxKind: ts.SyntaxKind;\n\n switch (selectorName) {\n case 'class':\n selectorSyntaxKind = ts.SyntaxKind.ClassDeclaration;\n break;\n case 'enum':\n selectorSyntaxKind = ts.SyntaxKind.EnumDeclaration;\n break;\n case 'function':\n selectorSyntaxKind = ts.SyntaxKind.FunctionDeclaration;\n break;\n case 'interface':\n selectorSyntaxKind = ts.SyntaxKind.InterfaceDeclaration;\n break;\n case 'namespace':\n selectorSyntaxKind = ts.SyntaxKind.ModuleDeclaration;\n break;\n case 'type':\n selectorSyntaxKind = ts.SyntaxKind.TypeAliasDeclaration;\n break;\n case 'variable':\n selectorSyntaxKind = ts.SyntaxKind.VariableDeclaration;\n break;\n default:\n return new ResolverFailure(`Unsupported system selector \"${selectorName}\"`);\n }\n\n const matches: AstDeclaration[] = astDeclarations.filter(\n (x) => x.declaration.kind === selectorSyntaxKind\n );\n if (matches.length === 0) {\n return new ResolverFailure(\n `A declaration for \"${astSymbolName}\" was not found that matches the` +\n ` TSDoc selector \"${selectorName}\"`\n );\n }\n if (matches.length > 1) {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(matches);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `More than one declaration \"${astSymbolName}\" matches the TSDoc selector \"${selectorName}\"`\n );\n }\n return matches[0];\n }\n\n private _selectUsingIndexSelector(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberSelector: tsdoc.DocMemberSelector,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const selectorOverloadIndex: number = parseInt(memberSelector.selector, 10);\n\n const matches: AstDeclaration[] = [];\n for (const astDeclaration of astDeclarations) {\n const overloadIndex: number = this._collector.getOverloadIndex(astDeclaration);\n if (overloadIndex === selectorOverloadIndex) {\n matches.push(astDeclaration);\n }\n }\n\n if (matches.length === 0) {\n return new ResolverFailure(\n `An overload for \"${astSymbolName}\" was not found that matches the` +\n ` TSDoc selector \":${selectorOverloadIndex}\"`\n );\n }\n if (matches.length > 1) {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(matches);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `More than one declaration for \"${astSymbolName}\" matches the` +\n ` TSDoc selector \":${selectorOverloadIndex}\"`\n );\n }\n return matches[0];\n }\n\n /**\n * This resolves an ambiguous match in the case where the extra matches are all ancillary declarations,\n * except for one match that is the main declaration.\n */\n private _tryDisambiguateAncillaryMatches(\n matches: ReadonlyArray<AstDeclaration>\n ): AstDeclaration | undefined {\n let result: AstDeclaration | undefined = undefined;\n\n for (const match of matches) {\n const declarationMetadata: DeclarationMetadata = this._collector.fetchDeclarationMetadata(match);\n if (!declarationMetadata.isAncillary) {\n if (result) {\n return undefined; // more than one match\n }\n result = match;\n }\n }\n return result;\n }\n}\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { InternalError } from '@rushstack/node-core-library';
|
|
4
|
+
import { AstEntity } from './AstEntity';
|
|
5
|
+
/**
|
|
6
|
+
* The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's
|
|
7
|
+
* ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The AstSymbol represents the ts.Symbol information for an AstDeclaration. For example,
|
|
11
|
+
* if a method has 3 overloads, each overloaded signature will have its own AstDeclaration,
|
|
12
|
+
* but they will all share a common AstSymbol.
|
|
13
|
+
*
|
|
14
|
+
* For nested definitions, the AstSymbol has a unique parent (i.e. AstSymbol.rootAstSymbol),
|
|
15
|
+
* but the parent/children for each AstDeclaration may be different. Consider this example:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* export namespace N {
|
|
19
|
+
* export function f(): void { }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* export interface N {
|
|
23
|
+
* g(): void;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Note how the parent/child relationships are different for the symbol tree versus
|
|
28
|
+
* the declaration tree, and the declaration tree has two roots:
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* AstSymbol tree: AstDeclaration tree:
|
|
32
|
+
* - N - N (namespace)
|
|
33
|
+
* - f - f
|
|
34
|
+
* - g - N (interface)
|
|
35
|
+
* - g
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export class AstSymbol extends AstEntity {
|
|
39
|
+
constructor(options) {
|
|
40
|
+
super();
|
|
41
|
+
// This flag is unused if this is not the root symbol.
|
|
42
|
+
// Being "analyzed" is a property of the root symbol.
|
|
43
|
+
this._analyzed = false;
|
|
44
|
+
this.followedSymbol = options.followedSymbol;
|
|
45
|
+
this.localName = options.localName;
|
|
46
|
+
this.isExternal = options.isExternal;
|
|
47
|
+
this.nominalAnalysis = options.nominalAnalysis;
|
|
48
|
+
this.parentAstSymbol = options.parentAstSymbol;
|
|
49
|
+
this.rootAstSymbol = options.rootAstSymbol || this;
|
|
50
|
+
this._astDeclarations = [];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The one or more declarations for this symbol.
|
|
54
|
+
* @remarks
|
|
55
|
+
* For example, if this symbol is a method, then the declarations might be
|
|
56
|
+
* various method overloads. If this symbol is a namespace, then the declarations
|
|
57
|
+
* might be separate namespace blocks with the same name that get combined via
|
|
58
|
+
* declaration merging.
|
|
59
|
+
*/
|
|
60
|
+
get astDeclarations() {
|
|
61
|
+
return this._astDeclarations;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the AstSymbolTable.analyze() was called for this object.
|
|
65
|
+
* See that function for details.
|
|
66
|
+
* @remarks
|
|
67
|
+
* AstSymbolTable.analyze() is always performed on the root AstSymbol. This function
|
|
68
|
+
* returns true if-and-only-if the root symbol was analyzed.
|
|
69
|
+
*/
|
|
70
|
+
get analyzed() {
|
|
71
|
+
return this.rootAstSymbol._analyzed;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* This is an internal callback used when the AstSymbolTable attaches a new
|
|
75
|
+
* AstDeclaration to this object.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
_notifyDeclarationAttach(astDeclaration) {
|
|
79
|
+
if (this.analyzed) {
|
|
80
|
+
throw new InternalError('_notifyDeclarationAttach() called after analysis is already complete');
|
|
81
|
+
}
|
|
82
|
+
this._astDeclarations.push(astDeclaration);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* This is an internal callback used when the AstSymbolTable.analyze()
|
|
86
|
+
* has processed this object.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
_notifyAnalyzed() {
|
|
90
|
+
if (this.parentAstSymbol) {
|
|
91
|
+
throw new InternalError('_notifyAnalyzed() called for an AstSymbol which is not the root');
|
|
92
|
+
}
|
|
93
|
+
this._analyzed = true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Helper that calls AstDeclaration.forEachDeclarationRecursive() for each AstDeclaration.
|
|
97
|
+
*/
|
|
98
|
+
forEachDeclarationRecursive(action) {
|
|
99
|
+
for (const astDeclaration of this.astDeclarations) {
|
|
100
|
+
astDeclaration.forEachDeclarationRecursive(action);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=AstSymbol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AstSymbol.js","sourceRoot":"","sources":["../../src/analyzer/AstSymbol.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAI3D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IA6DtC,YAAmB,OAA0B;QAC3C,KAAK,EAAE,CAAC;QALV,sDAAsD;QACtD,qDAAqD;QAC7C,cAAS,GAAY,KAAK,CAAC;QAKjC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;QACnD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,cAA8B;QAC5D,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,aAAa,CAAC,sEAAsE,CAAC,CAAC;QAClG,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,eAAe;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,IAAI,aAAa,CAAC,iEAAiE,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,MAAgD;QACjF,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAClD,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { AstDeclaration } from './AstDeclaration';\nimport { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstSymbol\n */\nexport interface IAstSymbolOptions {\n readonly followedSymbol: ts.Symbol;\n readonly localName: string;\n readonly isExternal: boolean;\n readonly nominalAnalysis: boolean;\n readonly parentAstSymbol: AstSymbol | undefined;\n readonly rootAstSymbol: AstSymbol | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstSymbol represents the ts.Symbol information for an AstDeclaration. For example,\n * if a method has 3 overloads, each overloaded signature will have its own AstDeclaration,\n * but they will all share a common AstSymbol.\n *\n * For nested definitions, the AstSymbol has a unique parent (i.e. AstSymbol.rootAstSymbol),\n * but the parent/children for each AstDeclaration may be different. Consider this example:\n *\n * ```ts\n * export namespace N {\n * export function f(): void { }\n * }\n *\n * export interface N {\n * g(): void;\n * }\n * ```\n *\n * Note how the parent/child relationships are different for the symbol tree versus\n * the declaration tree, and the declaration tree has two roots:\n *\n * ```\n * AstSymbol tree: AstDeclaration tree:\n * - N - N (namespace)\n * - f - f\n * - g - N (interface)\n * - g\n * ```\n */\nexport class AstSymbol extends AstEntity {\n /** {@inheritdoc} */\n public readonly localName: string; // abstract\n\n /**\n * If true, then the `followedSymbol` (i.e. original declaration) of this symbol\n * is not part of the working package. The working package may still export this symbol,\n * but if so it should be emitted as an alias such as `export { X } from \"package1\";`.\n */\n public readonly isExternal: boolean;\n\n /**\n * The compiler symbol where this type was defined, after following any aliases.\n *\n * @remarks\n * This is a normal form that can be reached from any symbol alias by calling\n * `TypeScriptHelpers.followAliases()`. It can be compared to determine whether two\n * symbols refer to the same underlying type.\n */\n public readonly followedSymbol: ts.Symbol;\n\n /**\n * If true, then this AstSymbol represents a foreign object whose structure will be\n * ignored. The AstDeclaration objects will not have any parent or children, and its references\n * will not be analyzed.\n *\n * Nominal symbols are tracked e.g. when they are reexported by the working package.\n */\n public readonly nominalAnalysis: boolean;\n\n /**\n * Returns the symbol of the parent of this AstSymbol, or undefined if there is no parent.\n * @remarks\n * If a symbol has multiple declarations, we assume (as an axiom) that their parent\n * declarations will belong to the same symbol. This means that the \"parent\" of a\n * symbol is a well-defined concept. However, the \"children\" of a symbol are not very\n * meaningful, because different declarations may have different nested members,\n * so we usually need to traverse declarations to find children.\n */\n public readonly parentAstSymbol: AstSymbol | undefined;\n\n /**\n * Returns the symbol of the root of the AstDeclaration hierarchy.\n * @remarks\n * NOTE: If this AstSymbol is the root, then rootAstSymbol will point to itself.\n */\n public readonly rootAstSymbol: AstSymbol;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `SymbolMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchSymbolMetadata()`.\n */\n public symbolMetadata: unknown;\n\n private readonly _astDeclarations: AstDeclaration[];\n\n // This flag is unused if this is not the root symbol.\n // Being \"analyzed\" is a property of the root symbol.\n private _analyzed: boolean = false;\n\n public constructor(options: IAstSymbolOptions) {\n super();\n\n this.followedSymbol = options.followedSymbol;\n this.localName = options.localName;\n this.isExternal = options.isExternal;\n this.nominalAnalysis = options.nominalAnalysis;\n this.parentAstSymbol = options.parentAstSymbol;\n this.rootAstSymbol = options.rootAstSymbol || this;\n this._astDeclarations = [];\n }\n\n /**\n * The one or more declarations for this symbol.\n * @remarks\n * For example, if this symbol is a method, then the declarations might be\n * various method overloads. If this symbol is a namespace, then the declarations\n * might be separate namespace blocks with the same name that get combined via\n * declaration merging.\n */\n public get astDeclarations(): ReadonlyArray<AstDeclaration> {\n return this._astDeclarations;\n }\n\n /**\n * Returns true if the AstSymbolTable.analyze() was called for this object.\n * See that function for details.\n * @remarks\n * AstSymbolTable.analyze() is always performed on the root AstSymbol. This function\n * returns true if-and-only-if the root symbol was analyzed.\n */\n public get analyzed(): boolean {\n return this.rootAstSymbol._analyzed;\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * AstDeclaration to this object.\n * @internal\n */\n public _notifyDeclarationAttach(astDeclaration: AstDeclaration): void {\n if (this.analyzed) {\n throw new InternalError('_notifyDeclarationAttach() called after analysis is already complete');\n }\n this._astDeclarations.push(astDeclaration);\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable.analyze()\n * has processed this object.\n * @internal\n */\n public _notifyAnalyzed(): void {\n if (this.parentAstSymbol) {\n throw new InternalError('_notifyAnalyzed() called for an AstSymbol which is not the root');\n }\n this._analyzed = true;\n }\n\n /**\n * Helper that calls AstDeclaration.forEachDeclarationRecursive() for each AstDeclaration.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n for (const astDeclaration of this.astDeclarations) {\n astDeclaration.forEachDeclarationRecursive(action);\n }\n }\n}\n"]}
|