@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,292 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
/* eslint-disable no-bitwise */
|
|
4
|
+
import * as ts from 'typescript';
|
|
5
|
+
import { DeclarationReference, ModuleSource, GlobalSource, Navigation, Meaning } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';
|
|
6
|
+
import { InternalError } from '@rushstack/node-core-library';
|
|
7
|
+
import { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';
|
|
8
|
+
import { TypeScriptInternals } from '../analyzer/TypeScriptInternals';
|
|
9
|
+
import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
|
|
10
|
+
export class DeclarationReferenceGenerator {
|
|
11
|
+
constructor(collector) {
|
|
12
|
+
this._collector = collector;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Gets the UID for a TypeScript Identifier that references a type.
|
|
16
|
+
*/
|
|
17
|
+
getDeclarationReferenceForIdentifier(node) {
|
|
18
|
+
const symbol = this._collector.typeChecker.getSymbolAtLocation(node);
|
|
19
|
+
if (symbol !== undefined) {
|
|
20
|
+
const isExpression = DeclarationReferenceGenerator._isInExpressionContext(node);
|
|
21
|
+
return (this.getDeclarationReferenceForSymbol(symbol, isExpression ? ts.SymbolFlags.Value : ts.SymbolFlags.Type) ||
|
|
22
|
+
this.getDeclarationReferenceForSymbol(symbol, isExpression ? ts.SymbolFlags.Type : ts.SymbolFlags.Value) ||
|
|
23
|
+
this.getDeclarationReferenceForSymbol(symbol, ts.SymbolFlags.Namespace));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the DeclarationReference for a TypeScript Symbol for a given meaning.
|
|
28
|
+
*/
|
|
29
|
+
getDeclarationReferenceForSymbol(symbol, meaning) {
|
|
30
|
+
return this._symbolToDeclarationReference(symbol, meaning, /*includeModuleSymbols*/ false);
|
|
31
|
+
}
|
|
32
|
+
static _isInExpressionContext(node) {
|
|
33
|
+
switch (node.parent.kind) {
|
|
34
|
+
case ts.SyntaxKind.TypeQuery:
|
|
35
|
+
case ts.SyntaxKind.ComputedPropertyName:
|
|
36
|
+
return true;
|
|
37
|
+
case ts.SyntaxKind.QualifiedName:
|
|
38
|
+
return DeclarationReferenceGenerator._isInExpressionContext(node.parent);
|
|
39
|
+
default:
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
static _isExternalModuleSymbol(symbol) {
|
|
44
|
+
return (!!(symbol.flags & ts.SymbolFlags.ValueModule) &&
|
|
45
|
+
symbol.valueDeclaration !== undefined &&
|
|
46
|
+
ts.isSourceFile(symbol.valueDeclaration));
|
|
47
|
+
}
|
|
48
|
+
static _isSameSymbol(left, right) {
|
|
49
|
+
return (left === right ||
|
|
50
|
+
!!(left &&
|
|
51
|
+
left.valueDeclaration &&
|
|
52
|
+
right.valueDeclaration &&
|
|
53
|
+
left.valueDeclaration === right.valueDeclaration));
|
|
54
|
+
}
|
|
55
|
+
_getNavigationToSymbol(symbol) {
|
|
56
|
+
const declaration = TypeScriptHelpers.tryGetADeclaration(symbol);
|
|
57
|
+
const sourceFile = declaration === null || declaration === void 0 ? void 0 : declaration.getSourceFile();
|
|
58
|
+
const parent = TypeScriptInternals.getSymbolParent(symbol);
|
|
59
|
+
// If it's global or from an external library, then use either Members or Exports. It's not possible for
|
|
60
|
+
// global symbols or external library symbols to be Locals.
|
|
61
|
+
const isGlobal = !!sourceFile && !ts.isExternalModule(sourceFile);
|
|
62
|
+
const isFromExternalLibrary = !!sourceFile && this._collector.program.isSourceFileFromExternalLibrary(sourceFile);
|
|
63
|
+
if (isGlobal || isFromExternalLibrary) {
|
|
64
|
+
if (parent &&
|
|
65
|
+
parent.members &&
|
|
66
|
+
DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)) {
|
|
67
|
+
return Navigation.Members;
|
|
68
|
+
}
|
|
69
|
+
return Navigation.Exports;
|
|
70
|
+
}
|
|
71
|
+
// Otherwise, this symbol is from the current package. If we've found an associated consumable
|
|
72
|
+
// `CollectorEntity`, then use Exports. We use `consumable` here instead of `exported` because
|
|
73
|
+
// if the symbol is exported from a non-consumable `AstNamespaceImport`, we don't want to use
|
|
74
|
+
// Exports. We should use Locals instead.
|
|
75
|
+
const entity = this._collector.tryGetEntityForSymbol(symbol);
|
|
76
|
+
if (entity === null || entity === void 0 ? void 0 : entity.consumable) {
|
|
77
|
+
return Navigation.Exports;
|
|
78
|
+
}
|
|
79
|
+
// If its parent symbol is not a source file, then use either Exports or Members. If the parent symbol
|
|
80
|
+
// is a source file, but it wasn't exported from the package entry point (in the check above), then the
|
|
81
|
+
// symbol is a local, so fall through below.
|
|
82
|
+
if (parent && !DeclarationReferenceGenerator._isExternalModuleSymbol(parent)) {
|
|
83
|
+
if (parent.members &&
|
|
84
|
+
DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)) {
|
|
85
|
+
return Navigation.Members;
|
|
86
|
+
}
|
|
87
|
+
return Navigation.Exports;
|
|
88
|
+
}
|
|
89
|
+
// Otherwise, we have a local symbol, so use a Locals navigation. These are either:
|
|
90
|
+
//
|
|
91
|
+
// 1. Symbols that are exported from a file module but not the package entry point.
|
|
92
|
+
// 2. Symbols that are not exported from their parent module.
|
|
93
|
+
return Navigation.Locals;
|
|
94
|
+
}
|
|
95
|
+
static _getMeaningOfSymbol(symbol, meaning) {
|
|
96
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Class) {
|
|
97
|
+
return Meaning.Class;
|
|
98
|
+
}
|
|
99
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Enum) {
|
|
100
|
+
return Meaning.Enum;
|
|
101
|
+
}
|
|
102
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Interface) {
|
|
103
|
+
return Meaning.Interface;
|
|
104
|
+
}
|
|
105
|
+
if (symbol.flags & meaning & ts.SymbolFlags.TypeAlias) {
|
|
106
|
+
return Meaning.TypeAlias;
|
|
107
|
+
}
|
|
108
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Function) {
|
|
109
|
+
return Meaning.Function;
|
|
110
|
+
}
|
|
111
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Variable) {
|
|
112
|
+
return Meaning.Variable;
|
|
113
|
+
}
|
|
114
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Module) {
|
|
115
|
+
return Meaning.Namespace;
|
|
116
|
+
}
|
|
117
|
+
if (symbol.flags & meaning & ts.SymbolFlags.ClassMember) {
|
|
118
|
+
return Meaning.Member;
|
|
119
|
+
}
|
|
120
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Constructor) {
|
|
121
|
+
return Meaning.Constructor;
|
|
122
|
+
}
|
|
123
|
+
if (symbol.flags & meaning & ts.SymbolFlags.EnumMember) {
|
|
124
|
+
return Meaning.Member;
|
|
125
|
+
}
|
|
126
|
+
if (symbol.flags & meaning & ts.SymbolFlags.Signature) {
|
|
127
|
+
if (symbol.escapedName === ts.InternalSymbolName.Call) {
|
|
128
|
+
return Meaning.CallSignature;
|
|
129
|
+
}
|
|
130
|
+
if (symbol.escapedName === ts.InternalSymbolName.New) {
|
|
131
|
+
return Meaning.ConstructSignature;
|
|
132
|
+
}
|
|
133
|
+
if (symbol.escapedName === ts.InternalSymbolName.Index) {
|
|
134
|
+
return Meaning.IndexSignature;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (symbol.flags & meaning & ts.SymbolFlags.TypeParameter) {
|
|
138
|
+
// This should have already been handled in `getDeclarationReferenceOfSymbol`.
|
|
139
|
+
throw new InternalError('Not supported.');
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
_symbolToDeclarationReference(symbol, meaning, includeModuleSymbols) {
|
|
144
|
+
const declaration = TypeScriptHelpers.tryGetADeclaration(symbol);
|
|
145
|
+
const sourceFile = declaration === null || declaration === void 0 ? void 0 : declaration.getSourceFile();
|
|
146
|
+
let followedSymbol = symbol;
|
|
147
|
+
if (followedSymbol.flags & ts.SymbolFlags.ExportValue) {
|
|
148
|
+
followedSymbol = this._collector.typeChecker.getExportSymbolOfSymbol(followedSymbol);
|
|
149
|
+
}
|
|
150
|
+
if (followedSymbol.flags & ts.SymbolFlags.Alias) {
|
|
151
|
+
followedSymbol = this._collector.typeChecker.getAliasedSymbol(followedSymbol);
|
|
152
|
+
// Without this logic, we end up following the symbol `ns` in `import * as ns from './file'` to
|
|
153
|
+
// the actual file `file.ts`. We don't want to do this, so revert to the original symbol.
|
|
154
|
+
if (followedSymbol.flags & ts.SymbolFlags.ValueModule) {
|
|
155
|
+
followedSymbol = symbol;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (DeclarationReferenceGenerator._isExternalModuleSymbol(followedSymbol)) {
|
|
159
|
+
if (!includeModuleSymbols) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));
|
|
163
|
+
}
|
|
164
|
+
// Do not generate a declaration reference for a type parameter.
|
|
165
|
+
if (followedSymbol.flags & ts.SymbolFlags.TypeParameter) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
let parentRef = this._getParentReference(followedSymbol);
|
|
169
|
+
if (!parentRef) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
let localName = followedSymbol.name;
|
|
173
|
+
const entity = this._collector.tryGetEntityForSymbol(followedSymbol);
|
|
174
|
+
if (entity === null || entity === void 0 ? void 0 : entity.nameForEmit) {
|
|
175
|
+
localName = entity.nameForEmit;
|
|
176
|
+
}
|
|
177
|
+
if (followedSymbol.escapedName === ts.InternalSymbolName.Constructor) {
|
|
178
|
+
localName = 'constructor';
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const wellKnownName = TypeScriptHelpers.tryDecodeWellKnownSymbolName(followedSymbol.escapedName);
|
|
182
|
+
if (wellKnownName) {
|
|
183
|
+
// TypeScript binds well-known ECMAScript symbols like 'Symbol.iterator' as '__@iterator'.
|
|
184
|
+
// This converts a string like '__@iterator' into the property name '[Symbol.iterator]'.
|
|
185
|
+
localName = wellKnownName;
|
|
186
|
+
}
|
|
187
|
+
else if (TypeScriptHelpers.isUniqueSymbolName(followedSymbol.escapedName)) {
|
|
188
|
+
for (const decl of followedSymbol.declarations || []) {
|
|
189
|
+
const declName = ts.getNameOfDeclaration(decl);
|
|
190
|
+
if (declName && ts.isComputedPropertyName(declName)) {
|
|
191
|
+
const lateName = TypeScriptHelpers.tryGetLateBoundName(declName);
|
|
192
|
+
if (lateName !== undefined) {
|
|
193
|
+
localName = lateName;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const navigation = this._getNavigationToSymbol(followedSymbol);
|
|
201
|
+
// If the symbol is a global, ensure the source is global.
|
|
202
|
+
if (sourceFile && !ts.isExternalModule(sourceFile) && parentRef.source !== GlobalSource.instance) {
|
|
203
|
+
parentRef = new DeclarationReference(GlobalSource.instance);
|
|
204
|
+
}
|
|
205
|
+
return parentRef
|
|
206
|
+
.addNavigationStep(navigation, localName)
|
|
207
|
+
.withMeaning(DeclarationReferenceGenerator._getMeaningOfSymbol(followedSymbol, meaning));
|
|
208
|
+
}
|
|
209
|
+
_getParentReference(symbol) {
|
|
210
|
+
var _a;
|
|
211
|
+
const declaration = TypeScriptHelpers.tryGetADeclaration(symbol);
|
|
212
|
+
const sourceFile = declaration === null || declaration === void 0 ? void 0 : declaration.getSourceFile();
|
|
213
|
+
// Note that it's possible for a symbol to be exported from an entry point as well as one or more
|
|
214
|
+
// namespaces. In that case, it's not clear what to choose as its parent. Today's logic is neither
|
|
215
|
+
// perfect nor particularly stable to API items being renamed and shuffled around.
|
|
216
|
+
const entity = this._collector.tryGetEntityForSymbol(symbol);
|
|
217
|
+
if (entity) {
|
|
218
|
+
if (entity.exportedFromEntryPoint) {
|
|
219
|
+
return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));
|
|
220
|
+
}
|
|
221
|
+
const firstExportingConsumableParent = entity.getFirstExportingConsumableParent();
|
|
222
|
+
if (firstExportingConsumableParent &&
|
|
223
|
+
firstExportingConsumableParent.astEntity instanceof AstNamespaceImport) {
|
|
224
|
+
const parentSymbol = TypeScriptInternals.tryGetSymbolForDeclaration(firstExportingConsumableParent.astEntity.declaration, this._collector.typeChecker);
|
|
225
|
+
if (parentSymbol) {
|
|
226
|
+
return this._symbolToDeclarationReference(parentSymbol, parentSymbol.flags,
|
|
227
|
+
/*includeModuleSymbols*/ true);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// Next, try to find a parent symbol via the symbol tree.
|
|
232
|
+
const parentSymbol = TypeScriptInternals.getSymbolParent(symbol);
|
|
233
|
+
if (parentSymbol) {
|
|
234
|
+
return this._symbolToDeclarationReference(parentSymbol, parentSymbol.flags,
|
|
235
|
+
/*includeModuleSymbols*/ true);
|
|
236
|
+
}
|
|
237
|
+
// If that doesn't work, try to find a parent symbol via the node tree. As far as we can tell,
|
|
238
|
+
// this logic is only needed for local symbols within namespaces. For example:
|
|
239
|
+
//
|
|
240
|
+
// ```
|
|
241
|
+
// export namespace n {
|
|
242
|
+
// type SomeType = number;
|
|
243
|
+
// export function someFunction(): SomeType { return 5; }
|
|
244
|
+
// }
|
|
245
|
+
// ```
|
|
246
|
+
//
|
|
247
|
+
// In the example above, `SomeType` doesn't have a parent symbol per the TS internal API above,
|
|
248
|
+
// but its reference still needs to be qualified with the parent reference for `n`.
|
|
249
|
+
const grandParent = (_a = declaration === null || declaration === void 0 ? void 0 : declaration.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
250
|
+
if (grandParent && ts.isModuleDeclaration(grandParent)) {
|
|
251
|
+
const grandParentSymbol = TypeScriptInternals.tryGetSymbolForDeclaration(grandParent, this._collector.typeChecker);
|
|
252
|
+
if (grandParentSymbol) {
|
|
253
|
+
return this._symbolToDeclarationReference(grandParentSymbol, grandParentSymbol.flags,
|
|
254
|
+
/*includeModuleSymbols*/ true);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// At this point, we have a local symbol in a module.
|
|
258
|
+
if (sourceFile && ts.isExternalModule(sourceFile)) {
|
|
259
|
+
return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
return new DeclarationReference(GlobalSource.instance);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
_getPackageName(sourceFile) {
|
|
266
|
+
if (this._collector.program.isSourceFileFromExternalLibrary(sourceFile)) {
|
|
267
|
+
const packageJson = this._collector.packageJsonLookup.tryLoadNodePackageJsonFor(sourceFile.fileName);
|
|
268
|
+
if (packageJson && packageJson.name) {
|
|
269
|
+
return packageJson.name;
|
|
270
|
+
}
|
|
271
|
+
return DeclarationReferenceGenerator.unknownReference;
|
|
272
|
+
}
|
|
273
|
+
return this._collector.workingPackage.name;
|
|
274
|
+
}
|
|
275
|
+
_sourceFileToModuleSource(sourceFile) {
|
|
276
|
+
if (sourceFile && ts.isExternalModule(sourceFile)) {
|
|
277
|
+
const packageName = this._getPackageName(sourceFile);
|
|
278
|
+
if (this._collector.bundledPackageNames.has(packageName)) {
|
|
279
|
+
// The api-extractor.json config file has a "bundledPackages" setting, which causes imports from
|
|
280
|
+
// certain NPM packages to be treated as part of the working project. In this case, we need to
|
|
281
|
+
// substitute the working package name.
|
|
282
|
+
return new ModuleSource(this._collector.workingPackage.name);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
return new ModuleSource(packageName);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return GlobalSource.instance;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
DeclarationReferenceGenerator.unknownReference = '?';
|
|
292
|
+
//# sourceMappingURL=DeclarationReferenceGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclarationReferenceGenerator.js","sourceRoot":"","sources":["../../src/generators/DeclarationReferenceGenerator.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,+BAA+B;AAC/B,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,OAAO,EACR,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAyB,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,OAAO,6BAA6B;IAKxC,YAAmB,SAAoB;QACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,oCAAoC,CAAC,IAAmB;QAC7D,MAAM,MAAM,GAA0B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5F,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,YAAY,GAAY,6BAA6B,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;YACzF,OAAO,CACL,IAAI,CAAC,gCAAgC,CACnC,MAAM,EACN,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAC1D;gBACD,IAAI,CAAC,gCAAgC,CACnC,MAAM,EACN,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI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A+B,CAAC,UAAU,CAAC,EAAE,CAAC;YACxE,MAAM,WAAW,GACf,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAEnF,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;gBACpC,OAAO,WAAW,CAAC,IAAI,CAAC;YAC1B,CAAC;YACD,OAAO,6BAA6B,CAAC,gBAAgB,CAAC;QACxD,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC;IAC7C,CAAC;IAEO,yBAAyB,CAAC,UAAqC;QACrE,IAAI,UAAU,IAAI,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;YAClD,MAAM,WAAW,GAAW,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAE7D,IAAI,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzD,gGAAgG;gBAChG,+FAA+F;gBAC/F,uCAAuC;gBACvC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;;AAtWsB,8CAAgB,GAAW,GAAG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable no-bitwise */\nimport * as ts from 'typescript';\n\nimport {\n DeclarationReference,\n ModuleSource,\n GlobalSource,\n Navigation,\n Meaning\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport { type INodePackageJson, InternalError } from '@rushstack/node-core-library';\n\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { TypeScriptInternals } from '../analyzer/TypeScriptInternals';\nimport type { Collector } from '../collector/Collector';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\n\nexport class DeclarationReferenceGenerator {\n public static readonly unknownReference: string = '?';\n\n private _collector: Collector;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n }\n\n /**\n * Gets the UID for a TypeScript Identifier that references a type.\n */\n public getDeclarationReferenceForIdentifier(node: ts.Identifier): DeclarationReference | undefined {\n const symbol: ts.Symbol | undefined = this._collector.typeChecker.getSymbolAtLocation(node);\n if (symbol !== undefined) {\n const isExpression: boolean = DeclarationReferenceGenerator._isInExpressionContext(node);\n return (\n this.getDeclarationReferenceForSymbol(\n symbol,\n isExpression ? ts.SymbolFlags.Value : ts.SymbolFlags.Type\n ) ||\n this.getDeclarationReferenceForSymbol(\n symbol,\n isExpression ? ts.SymbolFlags.Type : ts.SymbolFlags.Value\n ) ||\n this.getDeclarationReferenceForSymbol(symbol, ts.SymbolFlags.Namespace)\n );\n }\n }\n\n /**\n * Gets the DeclarationReference for a TypeScript Symbol for a given meaning.\n */\n public getDeclarationReferenceForSymbol(\n symbol: ts.Symbol,\n meaning: ts.SymbolFlags\n ): DeclarationReference | undefined {\n return this._symbolToDeclarationReference(symbol, meaning, /*includeModuleSymbols*/ false);\n }\n\n private static _isInExpressionContext(node: ts.Node): boolean {\n switch (node.parent.kind) {\n case ts.SyntaxKind.TypeQuery:\n case ts.SyntaxKind.ComputedPropertyName:\n return true;\n case ts.SyntaxKind.QualifiedName:\n return DeclarationReferenceGenerator._isInExpressionContext(node.parent);\n default:\n return false;\n }\n }\n\n private static _isExternalModuleSymbol(symbol: ts.Symbol): boolean {\n return (\n !!(symbol.flags & ts.SymbolFlags.ValueModule) &&\n symbol.valueDeclaration !== undefined &&\n ts.isSourceFile(symbol.valueDeclaration)\n );\n }\n\n private static _isSameSymbol(left: ts.Symbol | undefined, right: ts.Symbol): boolean {\n return (\n left === right ||\n !!(\n left &&\n left.valueDeclaration &&\n right.valueDeclaration &&\n left.valueDeclaration === right.valueDeclaration\n )\n );\n }\n\n private _getNavigationToSymbol(symbol: ts.Symbol): Navigation {\n const declaration: ts.Declaration | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n const parent: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(symbol);\n\n // If it's global or from an external library, then use either Members or Exports. It's not possible for\n // global symbols or external library symbols to be Locals.\n const isGlobal: boolean = !!sourceFile && !ts.isExternalModule(sourceFile);\n const isFromExternalLibrary: boolean =\n !!sourceFile && this._collector.program.isSourceFileFromExternalLibrary(sourceFile);\n if (isGlobal || isFromExternalLibrary) {\n if (\n parent &&\n parent.members &&\n DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)\n ) {\n return Navigation.Members;\n }\n\n return Navigation.Exports;\n }\n\n // Otherwise, this symbol is from the current package. If we've found an associated consumable\n // `CollectorEntity`, then use Exports. We use `consumable` here instead of `exported` because\n // if the symbol is exported from a non-consumable `AstNamespaceImport`, we don't want to use\n // Exports. We should use Locals instead.\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(symbol);\n if (entity?.consumable) {\n return Navigation.Exports;\n }\n\n // If its parent symbol is not a source file, then use either Exports or Members. If the parent symbol\n // is a source file, but it wasn't exported from the package entry point (in the check above), then the\n // symbol is a local, so fall through below.\n if (parent && !DeclarationReferenceGenerator._isExternalModuleSymbol(parent)) {\n if (\n parent.members &&\n DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)\n ) {\n return Navigation.Members;\n }\n\n return Navigation.Exports;\n }\n\n // Otherwise, we have a local symbol, so use a Locals navigation. These are either:\n //\n // 1. Symbols that are exported from a file module but not the package entry point.\n // 2. Symbols that are not exported from their parent module.\n return Navigation.Locals;\n }\n\n private static _getMeaningOfSymbol(symbol: ts.Symbol, meaning: ts.SymbolFlags): Meaning | undefined {\n if (symbol.flags & meaning & ts.SymbolFlags.Class) {\n return Meaning.Class;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Enum) {\n return Meaning.Enum;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Interface) {\n return Meaning.Interface;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.TypeAlias) {\n return Meaning.TypeAlias;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Function) {\n return Meaning.Function;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Variable) {\n return Meaning.Variable;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Module) {\n return Meaning.Namespace;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.ClassMember) {\n return Meaning.Member;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Constructor) {\n return Meaning.Constructor;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.EnumMember) {\n return Meaning.Member;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Signature) {\n if (symbol.escapedName === ts.InternalSymbolName.Call) {\n return Meaning.CallSignature;\n }\n if (symbol.escapedName === ts.InternalSymbolName.New) {\n return Meaning.ConstructSignature;\n }\n if (symbol.escapedName === ts.InternalSymbolName.Index) {\n return Meaning.IndexSignature;\n }\n }\n if (symbol.flags & meaning & ts.SymbolFlags.TypeParameter) {\n // This should have already been handled in `getDeclarationReferenceOfSymbol`.\n throw new InternalError('Not supported.');\n }\n return undefined;\n }\n\n private _symbolToDeclarationReference(\n symbol: ts.Symbol,\n meaning: ts.SymbolFlags,\n includeModuleSymbols: boolean\n ): DeclarationReference | undefined {\n const declaration: ts.Node | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n\n let followedSymbol: ts.Symbol = symbol;\n if (followedSymbol.flags & ts.SymbolFlags.ExportValue) {\n followedSymbol = this._collector.typeChecker.getExportSymbolOfSymbol(followedSymbol);\n }\n if (followedSymbol.flags & ts.SymbolFlags.Alias) {\n followedSymbol = this._collector.typeChecker.getAliasedSymbol(followedSymbol);\n\n // Without this logic, we end up following the symbol `ns` in `import * as ns from './file'` to\n // the actual file `file.ts`. We don't want to do this, so revert to the original symbol.\n if (followedSymbol.flags & ts.SymbolFlags.ValueModule) {\n followedSymbol = symbol;\n }\n }\n\n if (DeclarationReferenceGenerator._isExternalModuleSymbol(followedSymbol)) {\n if (!includeModuleSymbols) {\n return undefined;\n }\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n }\n\n // Do not generate a declaration reference for a type parameter.\n if (followedSymbol.flags & ts.SymbolFlags.TypeParameter) {\n return undefined;\n }\n\n let parentRef: DeclarationReference | undefined = this._getParentReference(followedSymbol);\n if (!parentRef) {\n return undefined;\n }\n\n let localName: string = followedSymbol.name;\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(followedSymbol);\n if (entity?.nameForEmit) {\n localName = entity.nameForEmit;\n }\n\n if (followedSymbol.escapedName === ts.InternalSymbolName.Constructor) {\n localName = 'constructor';\n } else {\n const wellKnownName: string | undefined = TypeScriptHelpers.tryDecodeWellKnownSymbolName(\n followedSymbol.escapedName\n );\n if (wellKnownName) {\n // TypeScript binds well-known ECMAScript symbols like 'Symbol.iterator' as '__@iterator'.\n // This converts a string like '__@iterator' into the property name '[Symbol.iterator]'.\n localName = wellKnownName;\n } else if (TypeScriptHelpers.isUniqueSymbolName(followedSymbol.escapedName)) {\n for (const decl of followedSymbol.declarations || []) {\n const declName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(decl);\n if (declName && ts.isComputedPropertyName(declName)) {\n const lateName: string | undefined = TypeScriptHelpers.tryGetLateBoundName(declName);\n if (lateName !== undefined) {\n localName = lateName;\n break;\n }\n }\n }\n }\n }\n\n const navigation: Navigation = this._getNavigationToSymbol(followedSymbol);\n\n // If the symbol is a global, ensure the source is global.\n if (sourceFile && !ts.isExternalModule(sourceFile) && parentRef.source !== GlobalSource.instance) {\n parentRef = new DeclarationReference(GlobalSource.instance);\n }\n\n return parentRef\n .addNavigationStep(navigation, localName)\n .withMeaning(DeclarationReferenceGenerator._getMeaningOfSymbol(followedSymbol, meaning));\n }\n\n private _getParentReference(symbol: ts.Symbol): DeclarationReference | undefined {\n const declaration: ts.Node | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n\n // Note that it's possible for a symbol to be exported from an entry point as well as one or more\n // namespaces. In that case, it's not clear what to choose as its parent. Today's logic is neither\n // perfect nor particularly stable to API items being renamed and shuffled around.\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(symbol);\n if (entity) {\n if (entity.exportedFromEntryPoint) {\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n }\n\n const firstExportingConsumableParent: CollectorEntity | undefined =\n entity.getFirstExportingConsumableParent();\n if (\n firstExportingConsumableParent &&\n firstExportingConsumableParent.astEntity instanceof AstNamespaceImport\n ) {\n const parentSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n firstExportingConsumableParent.astEntity.declaration,\n this._collector.typeChecker\n );\n if (parentSymbol) {\n return this._symbolToDeclarationReference(\n parentSymbol,\n parentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n }\n }\n\n // Next, try to find a parent symbol via the symbol tree.\n const parentSymbol: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(symbol);\n if (parentSymbol) {\n return this._symbolToDeclarationReference(\n parentSymbol,\n parentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n\n // If that doesn't work, try to find a parent symbol via the node tree. As far as we can tell,\n // this logic is only needed for local symbols within namespaces. For example:\n //\n // ```\n // export namespace n {\n // type SomeType = number;\n // export function someFunction(): SomeType { return 5; }\n // }\n // ```\n //\n // In the example above, `SomeType` doesn't have a parent symbol per the TS internal API above,\n // but its reference still needs to be qualified with the parent reference for `n`.\n const grandParent: ts.Node | undefined = declaration?.parent?.parent;\n if (grandParent && ts.isModuleDeclaration(grandParent)) {\n const grandParentSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n grandParent,\n this._collector.typeChecker\n );\n if (grandParentSymbol) {\n return this._symbolToDeclarationReference(\n grandParentSymbol,\n grandParentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n }\n\n // At this point, we have a local symbol in a module.\n if (sourceFile && ts.isExternalModule(sourceFile)) {\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n } else {\n return new DeclarationReference(GlobalSource.instance);\n }\n }\n\n private _getPackageName(sourceFile: ts.SourceFile): string {\n if (this._collector.program.isSourceFileFromExternalLibrary(sourceFile)) {\n const packageJson: INodePackageJson | undefined =\n this._collector.packageJsonLookup.tryLoadNodePackageJsonFor(sourceFile.fileName);\n\n if (packageJson && packageJson.name) {\n return packageJson.name;\n }\n return DeclarationReferenceGenerator.unknownReference;\n }\n return this._collector.workingPackage.name;\n }\n\n private _sourceFileToModuleSource(sourceFile: ts.SourceFile | undefined): GlobalSource | ModuleSource {\n if (sourceFile && ts.isExternalModule(sourceFile)) {\n const packageName: string = this._getPackageName(sourceFile);\n\n if (this._collector.bundledPackageNames.has(packageName)) {\n // The api-extractor.json config file has a \"bundledPackages\" setting, which causes imports from\n // certain NPM packages to be treated as part of the working project. In this case, we need to\n // substitute the working package name.\n return new ModuleSource(this._collector.workingPackage.name);\n } else {\n return new ModuleSource(packageName);\n }\n }\n return GlobalSource.instance;\n }\n}\n"]}
|
|
@@ -0,0 +1,227 @@
|
|
|
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 { InternalError } from '@rushstack/node-core-library';
|
|
5
|
+
import { AstImport, AstImportKind } from '../analyzer/AstImport';
|
|
6
|
+
import { AstDeclaration } from '../analyzer/AstDeclaration';
|
|
7
|
+
import { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';
|
|
8
|
+
import { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';
|
|
9
|
+
/**
|
|
10
|
+
* Some common code shared between DtsRollupGenerator and ApiReportGenerator.
|
|
11
|
+
*/
|
|
12
|
+
export class DtsEmitHelpers {
|
|
13
|
+
static emitImport(writer, collectorEntity, astImport) {
|
|
14
|
+
const importPrefix = astImport.isTypeOnlyEverywhere ? 'import type' : 'import';
|
|
15
|
+
switch (astImport.importKind) {
|
|
16
|
+
case AstImportKind.DefaultImport:
|
|
17
|
+
if (collectorEntity.nameForEmit !== astImport.exportName) {
|
|
18
|
+
writer.write(`${importPrefix} { default as ${collectorEntity.nameForEmit} }`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
writer.write(`${importPrefix} ${astImport.exportName}`);
|
|
22
|
+
}
|
|
23
|
+
writer.writeLine(` from '${astImport.modulePath}';`);
|
|
24
|
+
break;
|
|
25
|
+
case AstImportKind.NamedImport:
|
|
26
|
+
if (collectorEntity.nameForEmit === astImport.exportName) {
|
|
27
|
+
writer.write(`${importPrefix} { ${astImport.exportName} }`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
writer.write(`${importPrefix} { ${astImport.exportName} as ${collectorEntity.nameForEmit} }`);
|
|
31
|
+
}
|
|
32
|
+
writer.writeLine(` from '${astImport.modulePath}';`);
|
|
33
|
+
break;
|
|
34
|
+
case AstImportKind.StarImport:
|
|
35
|
+
writer.writeLine(`${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`);
|
|
36
|
+
break;
|
|
37
|
+
case AstImportKind.EqualsImport:
|
|
38
|
+
writer.writeLine(`${importPrefix} ${collectorEntity.nameForEmit} = require('${astImport.modulePath}');`);
|
|
39
|
+
break;
|
|
40
|
+
case AstImportKind.ImportType:
|
|
41
|
+
if (!astImport.exportName) {
|
|
42
|
+
writer.writeLine(`${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const topExportName = astImport.exportName.split('.')[0];
|
|
46
|
+
if (collectorEntity.nameForEmit === topExportName) {
|
|
47
|
+
writer.write(`${importPrefix} { ${topExportName} }`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
writer.write(`${importPrefix} { ${topExportName} as ${collectorEntity.nameForEmit} }`);
|
|
51
|
+
}
|
|
52
|
+
writer.writeLine(` from '${astImport.modulePath}';`);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new InternalError('Unimplemented AstImportKind');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
static emitNamedExport(writer, exportName, collectorEntity) {
|
|
60
|
+
if (exportName === ts.InternalSymbolName.Default) {
|
|
61
|
+
writer.writeLine(`export default ${collectorEntity.nameForEmit};`);
|
|
62
|
+
}
|
|
63
|
+
else if (collectorEntity.nameForEmit !== exportName) {
|
|
64
|
+
writer.writeLine(`export { ${collectorEntity.nameForEmit} as ${exportName} }`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
writer.writeLine(`export { ${exportName} }`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static emitStarExports(writer, collector) {
|
|
71
|
+
if (collector.starExportedExternalModulePaths.length > 0) {
|
|
72
|
+
writer.writeLine();
|
|
73
|
+
for (const starExportedExternalModulePath of collector.starExportedExternalModulePaths) {
|
|
74
|
+
writer.writeLine(`export * from "${starExportedExternalModulePath}";`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
static modifyImportTypeSpan(collector, span, astDeclaration, modifyNestedSpan) {
|
|
79
|
+
var _a, _b, _c, _d;
|
|
80
|
+
const node = span.node;
|
|
81
|
+
const referencedEntity = collector.tryGetEntityForNode(node);
|
|
82
|
+
if (referencedEntity) {
|
|
83
|
+
if (!referencedEntity.nameForEmit) {
|
|
84
|
+
// This should never happen
|
|
85
|
+
throw new InternalError('referencedEntry.nameForEmit is undefined');
|
|
86
|
+
}
|
|
87
|
+
let typeArgumentsText = '';
|
|
88
|
+
if (node.typeArguments && node.typeArguments.length > 0) {
|
|
89
|
+
// Type arguments have to be processed and written to the document
|
|
90
|
+
const lessThanTokenPos = span.children.findIndex((childSpan) => childSpan.node.kind === ts.SyntaxKind.LessThanToken);
|
|
91
|
+
const greaterThanTokenPos = span.children.findIndex((childSpan) => childSpan.node.kind === ts.SyntaxKind.GreaterThanToken);
|
|
92
|
+
if (lessThanTokenPos < 0 || greaterThanTokenPos <= lessThanTokenPos) {
|
|
93
|
+
throw new InternalError(`Invalid type arguments: ${node.getText()}\n` +
|
|
94
|
+
SourceFileLocationFormatter.formatDeclaration(node));
|
|
95
|
+
}
|
|
96
|
+
const typeArgumentsSpans = span.children.slice(lessThanTokenPos + 1, greaterThanTokenPos);
|
|
97
|
+
// Apply modifications to Span elements of typeArguments
|
|
98
|
+
typeArgumentsSpans.forEach((childSpan) => {
|
|
99
|
+
const childAstDeclaration = AstDeclaration.isSupportedSyntaxKind(childSpan.kind)
|
|
100
|
+
? collector.astSymbolTable.getChildAstDeclarationByNode(childSpan.node, astDeclaration)
|
|
101
|
+
: astDeclaration;
|
|
102
|
+
modifyNestedSpan(childSpan, childAstDeclaration);
|
|
103
|
+
});
|
|
104
|
+
const typeArgumentsStrings = typeArgumentsSpans.map((childSpan) => childSpan.getModifiedText());
|
|
105
|
+
typeArgumentsText = `<${typeArgumentsStrings.join(', ')}>`;
|
|
106
|
+
}
|
|
107
|
+
const separatorAfter = (_b = (_a = /(\s*)$/.exec(span.getText())) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
108
|
+
if (referencedEntity.astEntity instanceof AstImport &&
|
|
109
|
+
referencedEntity.astEntity.importKind === AstImportKind.ImportType &&
|
|
110
|
+
referencedEntity.astEntity.exportName) {
|
|
111
|
+
// For an ImportType with a namespace chain, only the top namespace is imported.
|
|
112
|
+
// Must add the original nested qualifiers to the rolled up import.
|
|
113
|
+
const qualifiersText = (_d = (_c = node.qualifier) === null || _c === void 0 ? void 0 : _c.getText()) !== null && _d !== void 0 ? _d : '';
|
|
114
|
+
const nestedQualifiersStart = qualifiersText.indexOf('.');
|
|
115
|
+
// Including the leading "."
|
|
116
|
+
const nestedQualifiersText = nestedQualifiersStart >= 0 ? qualifiersText.substring(nestedQualifiersStart) : '';
|
|
117
|
+
const replacement = `${referencedEntity.nameForEmit}${nestedQualifiersText}${typeArgumentsText}${separatorAfter}`;
|
|
118
|
+
span.modification.skipAll();
|
|
119
|
+
span.modification.prefix = replacement;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// Replace with internal symbol or AstImport
|
|
123
|
+
span.modification.skipAll();
|
|
124
|
+
span.modification.prefix = `${referencedEntity.nameForEmit}${typeArgumentsText}${separatorAfter}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks if an export keyword is part of an ExportDeclaration inside a namespace
|
|
130
|
+
* (e.g., "export { Foo, Bar };" inside "declare namespace SDK { ... }").
|
|
131
|
+
* In that case, the export keyword must be preserved, otherwise the output is invalid TypeScript.
|
|
132
|
+
*/
|
|
133
|
+
static isExportKeywordInNamespaceExportDeclaration(node) {
|
|
134
|
+
if (node.parent && ts.isExportDeclaration(node.parent)) {
|
|
135
|
+
const moduleBlock = TypeScriptHelpers.findFirstParent(node, ts.SyntaxKind.ModuleBlock);
|
|
136
|
+
if (moduleBlock) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Given an array that includes some parameter nodes, this returns an array of the same length;
|
|
144
|
+
* elements that are not undefined correspond to a parameter that should be renamed.
|
|
145
|
+
*/
|
|
146
|
+
static forEachParameterToNormalize(nodes, action) {
|
|
147
|
+
let actionIndex = 0;
|
|
148
|
+
// Optimistically assume that no parameters need to be normalized
|
|
149
|
+
for (actionIndex = 0; actionIndex < nodes.length; ++actionIndex) {
|
|
150
|
+
const parameter = nodes[actionIndex];
|
|
151
|
+
if (!ts.isParameter(parameter)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
action(parameter, undefined);
|
|
155
|
+
if (ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name)) {
|
|
156
|
+
// Our optimistic assumption was not true; we'll need to stop and calculate alreadyUsedNames
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (actionIndex === nodes.length) {
|
|
161
|
+
// Our optimistic assumption was true
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// First, calculate alreadyUsedNames
|
|
165
|
+
const alreadyUsedNames = [];
|
|
166
|
+
for (let index = 0; index < nodes.length; ++index) {
|
|
167
|
+
const parameter = nodes[index];
|
|
168
|
+
if (!ts.isParameter(parameter)) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (!(ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name))) {
|
|
172
|
+
alreadyUsedNames.push(parameter.name.text.trim());
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Now continue with the rest of the actions
|
|
176
|
+
for (; actionIndex < nodes.length; ++actionIndex) {
|
|
177
|
+
const parameter = nodes[actionIndex];
|
|
178
|
+
if (!ts.isParameter(parameter)) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name)) {
|
|
182
|
+
// Examples:
|
|
183
|
+
//
|
|
184
|
+
// function f({ y, z }: { y: string, z: string })
|
|
185
|
+
// ---> function f(input: { y: string, z: string })
|
|
186
|
+
//
|
|
187
|
+
// function f(x: number, [a, b]: [number, number])
|
|
188
|
+
// ---> function f(x: number, input: [number, number])
|
|
189
|
+
//
|
|
190
|
+
// Example of a naming collision:
|
|
191
|
+
//
|
|
192
|
+
// function f({ a }: { a: string }, { b }: { b: string }, input2: string)
|
|
193
|
+
// ---> function f(input: { a: string }, input3: { b: string }, input2: string)
|
|
194
|
+
const baseName = 'input';
|
|
195
|
+
let counter = 2;
|
|
196
|
+
let syntheticName = baseName;
|
|
197
|
+
while (alreadyUsedNames.includes(syntheticName)) {
|
|
198
|
+
syntheticName = `${baseName}${counter++}`;
|
|
199
|
+
}
|
|
200
|
+
alreadyUsedNames.push(syntheticName);
|
|
201
|
+
action(parameter, syntheticName);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
action(parameter, undefined);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
static normalizeParameterNames(signatureSpan) {
|
|
209
|
+
const syntheticNamesByNode = new Map();
|
|
210
|
+
DtsEmitHelpers.forEachParameterToNormalize(signatureSpan.node.getChildren(), (parameter, syntheticName) => {
|
|
211
|
+
if (syntheticName !== undefined) {
|
|
212
|
+
syntheticNamesByNode.set(parameter.name, syntheticName);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
if (syntheticNamesByNode.size > 0) {
|
|
216
|
+
signatureSpan.forEach((childSpan) => {
|
|
217
|
+
const syntheticName = syntheticNamesByNode.get(childSpan.node);
|
|
218
|
+
if (syntheticName !== undefined) {
|
|
219
|
+
childSpan.modification.prefix = syntheticName;
|
|
220
|
+
childSpan.modification.suffix = '';
|
|
221
|
+
childSpan.modification.omitChildren = true;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=DtsEmitHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DtsEmitHelpers.js","sourceRoot":"","sources":["../../src/generators/DtsEmitHelpers.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KA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CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,uBAAuB,CAAC,aAAmB;QACvD,MAAM,oBAAoB,GAAyB,IAAI,GAAG,EAAE,CAAC;QAE7D,cAAc,CAAC,2BAA2B,CACxC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,EAChC,CAAC,SAAkC,EAAE,aAAiC,EAAQ,EAAE;YAC9E,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CACF,CAAC;QAEF,IAAI,oBAAoB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAClC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAe,EAAQ,EAAE;gBAC9C,MAAM,aAAa,GAAuB,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACnF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;oBAChC,SAAS,CAAC,YAAY,CAAC,MAAM,GAAG,aAAa,CAAC;oBAC9C,SAAS,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,CAAC;oBACnC,SAAS,CAAC,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC;gBAC7C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,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 * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstImport, AstImportKind } from '../analyzer/AstImport';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { Collector } from '../collector/Collector';\nimport type { Span } from '../analyzer/Span';\nimport type { IndentedWriter } from './IndentedWriter';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\n\n/**\n * Some common code shared between DtsRollupGenerator and ApiReportGenerator.\n */\nexport class DtsEmitHelpers {\n public static emitImport(\n writer: IndentedWriter,\n collectorEntity: CollectorEntity,\n astImport: AstImport\n ): void {\n const importPrefix: string = astImport.isTypeOnlyEverywhere ? 'import type' : 'import';\n\n switch (astImport.importKind) {\n case AstImportKind.DefaultImport:\n if (collectorEntity.nameForEmit !== astImport.exportName) {\n writer.write(`${importPrefix} { default as ${collectorEntity.nameForEmit} }`);\n } else {\n writer.write(`${importPrefix} ${astImport.exportName}`);\n }\n writer.writeLine(` from '${astImport.modulePath}';`);\n break;\n case AstImportKind.NamedImport:\n if (collectorEntity.nameForEmit === astImport.exportName) {\n writer.write(`${importPrefix} { ${astImport.exportName} }`);\n } else {\n writer.write(`${importPrefix} { ${astImport.exportName} as ${collectorEntity.nameForEmit} }`);\n }\n writer.writeLine(` from '${astImport.modulePath}';`);\n break;\n case AstImportKind.StarImport:\n writer.writeLine(\n `${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`\n );\n break;\n case AstImportKind.EqualsImport:\n writer.writeLine(\n `${importPrefix} ${collectorEntity.nameForEmit} = require('${astImport.modulePath}');`\n );\n break;\n case AstImportKind.ImportType:\n if (!astImport.exportName) {\n writer.writeLine(\n `${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`\n );\n } else {\n const topExportName: string = astImport.exportName.split('.')[0];\n if (collectorEntity.nameForEmit === topExportName) {\n writer.write(`${importPrefix} { ${topExportName} }`);\n } else {\n writer.write(`${importPrefix} { ${topExportName} as ${collectorEntity.nameForEmit} }`);\n }\n writer.writeLine(` from '${astImport.modulePath}';`);\n }\n break;\n default:\n throw new InternalError('Unimplemented AstImportKind');\n }\n }\n\n public static emitNamedExport(\n writer: IndentedWriter,\n exportName: string,\n collectorEntity: CollectorEntity\n ): void {\n if (exportName === ts.InternalSymbolName.Default) {\n writer.writeLine(`export default ${collectorEntity.nameForEmit};`);\n } else if (collectorEntity.nameForEmit !== exportName) {\n writer.writeLine(`export { ${collectorEntity.nameForEmit} as ${exportName} }`);\n } else {\n writer.writeLine(`export { ${exportName} }`);\n }\n }\n\n public static emitStarExports(writer: IndentedWriter, collector: Collector): void {\n if (collector.starExportedExternalModulePaths.length > 0) {\n writer.writeLine();\n for (const starExportedExternalModulePath of collector.starExportedExternalModulePaths) {\n writer.writeLine(`export * from \"${starExportedExternalModulePath}\";`);\n }\n }\n }\n\n public static modifyImportTypeSpan(\n collector: Collector,\n span: Span,\n astDeclaration: AstDeclaration,\n modifyNestedSpan: (childSpan: Span, childAstDeclaration: AstDeclaration) => void\n ): void {\n const node: ts.ImportTypeNode = span.node as ts.ImportTypeNode;\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(node);\n\n if (referencedEntity) {\n if (!referencedEntity.nameForEmit) {\n // This should never happen\n\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n let typeArgumentsText: string = '';\n\n if (node.typeArguments && node.typeArguments.length > 0) {\n // Type arguments have to be processed and written to the document\n const lessThanTokenPos: number = span.children.findIndex(\n (childSpan) => childSpan.node.kind === ts.SyntaxKind.LessThanToken\n );\n const greaterThanTokenPos: number = span.children.findIndex(\n (childSpan) => childSpan.node.kind === ts.SyntaxKind.GreaterThanToken\n );\n\n if (lessThanTokenPos < 0 || greaterThanTokenPos <= lessThanTokenPos) {\n throw new InternalError(\n `Invalid type arguments: ${node.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(node)\n );\n }\n\n const typeArgumentsSpans: Span[] = span.children.slice(lessThanTokenPos + 1, greaterThanTokenPos);\n\n // Apply modifications to Span elements of typeArguments\n typeArgumentsSpans.forEach((childSpan) => {\n const childAstDeclaration: AstDeclaration = AstDeclaration.isSupportedSyntaxKind(childSpan.kind)\n ? collector.astSymbolTable.getChildAstDeclarationByNode(childSpan.node, astDeclaration)\n : astDeclaration;\n\n modifyNestedSpan(childSpan, childAstDeclaration);\n });\n\n const typeArgumentsStrings: string[] = typeArgumentsSpans.map((childSpan) =>\n childSpan.getModifiedText()\n );\n typeArgumentsText = `<${typeArgumentsStrings.join(', ')}>`;\n }\n\n const separatorAfter: string = /(\\s*)$/.exec(span.getText())?.[1] ?? '';\n\n if (\n referencedEntity.astEntity instanceof AstImport &&\n referencedEntity.astEntity.importKind === AstImportKind.ImportType &&\n referencedEntity.astEntity.exportName\n ) {\n // For an ImportType with a namespace chain, only the top namespace is imported.\n // Must add the original nested qualifiers to the rolled up import.\n const qualifiersText: string = node.qualifier?.getText() ?? '';\n const nestedQualifiersStart: number = qualifiersText.indexOf('.');\n // Including the leading \".\"\n const nestedQualifiersText: string =\n nestedQualifiersStart >= 0 ? qualifiersText.substring(nestedQualifiersStart) : '';\n\n const replacement: string = `${referencedEntity.nameForEmit}${nestedQualifiersText}${typeArgumentsText}${separatorAfter}`;\n\n span.modification.skipAll();\n span.modification.prefix = replacement;\n } else {\n // Replace with internal symbol or AstImport\n span.modification.skipAll();\n span.modification.prefix = `${referencedEntity.nameForEmit}${typeArgumentsText}${separatorAfter}`;\n }\n }\n }\n\n /**\n * Checks if an export keyword is part of an ExportDeclaration inside a namespace\n * (e.g., \"export { Foo, Bar };\" inside \"declare namespace SDK { ... }\").\n * In that case, the export keyword must be preserved, otherwise the output is invalid TypeScript.\n */\n public static isExportKeywordInNamespaceExportDeclaration(node: ts.Node): boolean {\n if (node.parent && ts.isExportDeclaration(node.parent)) {\n const moduleBlock: ts.ModuleBlock | undefined = TypeScriptHelpers.findFirstParent(\n node,\n ts.SyntaxKind.ModuleBlock\n );\n if (moduleBlock) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Given an array that includes some parameter nodes, this returns an array of the same length;\n * elements that are not undefined correspond to a parameter that should be renamed.\n */\n public static forEachParameterToNormalize(\n nodes: ArrayLike<ts.Node>,\n action: (parameter: ts.ParameterDeclaration, syntheticName: string | undefined) => void\n ): void {\n let actionIndex: number = 0;\n\n // Optimistically assume that no parameters need to be normalized\n for (actionIndex = 0; actionIndex < nodes.length; ++actionIndex) {\n const parameter: ts.Node = nodes[actionIndex];\n if (!ts.isParameter(parameter)) {\n continue;\n }\n action(parameter, undefined);\n if (ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name)) {\n // Our optimistic assumption was not true; we'll need to stop and calculate alreadyUsedNames\n break;\n }\n }\n\n if (actionIndex === nodes.length) {\n // Our optimistic assumption was true\n return;\n }\n\n // First, calculate alreadyUsedNames\n const alreadyUsedNames: string[] = [];\n\n for (let index: number = 0; index < nodes.length; ++index) {\n const parameter: ts.Node = nodes[index];\n if (!ts.isParameter(parameter)) {\n continue;\n }\n\n if (!(ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name))) {\n alreadyUsedNames.push(parameter.name.text.trim());\n }\n }\n\n // Now continue with the rest of the actions\n for (; actionIndex < nodes.length; ++actionIndex) {\n const parameter: ts.Node = nodes[actionIndex];\n if (!ts.isParameter(parameter)) {\n continue;\n }\n\n if (ts.isObjectBindingPattern(parameter.name) || ts.isArrayBindingPattern(parameter.name)) {\n // Examples:\n //\n // function f({ y, z }: { y: string, z: string })\n // ---> function f(input: { y: string, z: string })\n //\n // function f(x: number, [a, b]: [number, number])\n // ---> function f(x: number, input: [number, number])\n //\n // Example of a naming collision:\n //\n // function f({ a }: { a: string }, { b }: { b: string }, input2: string)\n // ---> function f(input: { a: string }, input3: { b: string }, input2: string)\n const baseName: string = 'input';\n let counter: number = 2;\n\n let syntheticName: string = baseName;\n while (alreadyUsedNames.includes(syntheticName)) {\n syntheticName = `${baseName}${counter++}`;\n }\n alreadyUsedNames.push(syntheticName);\n\n action(parameter, syntheticName);\n } else {\n action(parameter, undefined);\n }\n }\n }\n\n public static normalizeParameterNames(signatureSpan: Span): void {\n const syntheticNamesByNode: Map<ts.Node, string> = new Map();\n\n DtsEmitHelpers.forEachParameterToNormalize(\n signatureSpan.node.getChildren(),\n (parameter: ts.ParameterDeclaration, syntheticName: string | undefined): void => {\n if (syntheticName !== undefined) {\n syntheticNamesByNode.set(parameter.name, syntheticName);\n }\n }\n );\n\n if (syntheticNamesByNode.size > 0) {\n signatureSpan.forEach((childSpan: Span): void => {\n const syntheticName: string | undefined = syntheticNamesByNode.get(childSpan.node);\n if (syntheticName !== undefined) {\n childSpan.modification.prefix = syntheticName;\n childSpan.modification.suffix = '';\n childSpan.modification.omitChildren = true;\n }\n });\n }\n }\n}\n"]}
|