@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,725 @@
|
|
|
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 { TypeScriptHelpers } from './TypeScriptHelpers';
|
|
6
|
+
import { AstSymbol } from './AstSymbol';
|
|
7
|
+
import { AstImport, AstImportKind } from './AstImport';
|
|
8
|
+
import { AstModule } from './AstModule';
|
|
9
|
+
import { TypeScriptInternals } from './TypeScriptInternals';
|
|
10
|
+
import { SourceFileLocationFormatter } from './SourceFileLocationFormatter';
|
|
11
|
+
import { AstNamespaceImport } from './AstNamespaceImport';
|
|
12
|
+
import { SyntaxHelpers } from './SyntaxHelpers';
|
|
13
|
+
import { AstNamespaceExport } from './AstNamespaceExport';
|
|
14
|
+
/**
|
|
15
|
+
* The ExportAnalyzer is an internal part of AstSymbolTable that has been moved out into its own source file
|
|
16
|
+
* because it is a complex and mostly self-contained algorithm.
|
|
17
|
+
*
|
|
18
|
+
* Its job is to build up AstModule objects by crawling import statements to discover where declarations come from.
|
|
19
|
+
* This is conceptually the same as the compiler's own TypeChecker.getExportsOfModule(), except that when
|
|
20
|
+
* ExportAnalyzer encounters a declaration that was imported from an external package, it remembers how it was imported
|
|
21
|
+
* (i.e. the AstImport object). Today the compiler API does not expose this information, which is crucial for
|
|
22
|
+
* generating .d.ts rollups.
|
|
23
|
+
*/
|
|
24
|
+
export class ExportAnalyzer {
|
|
25
|
+
constructor(program, typeChecker, bundledPackageNames, astSymbolTable) {
|
|
26
|
+
this._astModulesByModuleSymbol = new Map();
|
|
27
|
+
// Used with isImportableAmbientSourceFile()
|
|
28
|
+
this._importableAmbientSourceFiles = new Set();
|
|
29
|
+
this._astImportsByKey = new Map();
|
|
30
|
+
this._astNamespaceImportByModule = new Map();
|
|
31
|
+
this._program = program;
|
|
32
|
+
this._typeChecker = typeChecker;
|
|
33
|
+
this._bundledPackageNames = bundledPackageNames;
|
|
34
|
+
this._astSymbolTable = astSymbolTable;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* For a given source file, this analyzes all of its exports and produces an AstModule object.
|
|
38
|
+
*
|
|
39
|
+
* @param moduleReference - contextual information about the import statement that took us to this source file.
|
|
40
|
+
* or `undefined` if this source file is the initial entry point
|
|
41
|
+
* @param isExternal - whether the given `moduleReference` is external.
|
|
42
|
+
*/
|
|
43
|
+
fetchAstModuleFromSourceFile(sourceFile, moduleReference, isExternal) {
|
|
44
|
+
const moduleSymbol = this._getModuleSymbolFromSourceFile(sourceFile, moduleReference);
|
|
45
|
+
// Don't traverse into a module that we already processed before:
|
|
46
|
+
// The compiler allows m1 to have "export * from 'm2'" and "export * from 'm3'",
|
|
47
|
+
// even if m2 and m3 both have "export * from 'm4'".
|
|
48
|
+
let astModule = this._astModulesByModuleSymbol.get(moduleSymbol);
|
|
49
|
+
if (!astModule) {
|
|
50
|
+
// (If moduleReference === undefined, then this is the entry point of the local project being analyzed.)
|
|
51
|
+
const externalModulePath = moduleReference !== undefined && isExternal ? moduleReference.moduleSpecifier : undefined;
|
|
52
|
+
astModule = new AstModule({ sourceFile, moduleSymbol, externalModulePath });
|
|
53
|
+
this._astModulesByModuleSymbol.set(moduleSymbol, astModule);
|
|
54
|
+
if (astModule.isExternal) {
|
|
55
|
+
// It's an external package, so do the special simplified analysis that doesn't crawl into referenced modules
|
|
56
|
+
for (const exportedSymbol of this._typeChecker.getExportsOfModule(moduleSymbol)) {
|
|
57
|
+
if (externalModulePath === undefined) {
|
|
58
|
+
throw new InternalError('Failed assertion: externalModulePath=undefined but astModule.isExternal=true');
|
|
59
|
+
}
|
|
60
|
+
const followedSymbol = TypeScriptHelpers.followAliases(exportedSymbol, this._typeChecker);
|
|
61
|
+
// Ignore virtual symbols that don't have any declarations
|
|
62
|
+
const arbitraryDeclaration = TypeScriptHelpers.tryGetADeclaration(followedSymbol);
|
|
63
|
+
if (arbitraryDeclaration) {
|
|
64
|
+
const astSymbol = this._astSymbolTable.fetchAstSymbol({
|
|
65
|
+
followedSymbol: followedSymbol,
|
|
66
|
+
isExternal: astModule.isExternal,
|
|
67
|
+
includeNominalAnalysis: true,
|
|
68
|
+
addIfMissing: true
|
|
69
|
+
});
|
|
70
|
+
if (!astSymbol) {
|
|
71
|
+
throw new Error(`Unsupported export ${JSON.stringify(exportedSymbol.name)}:\n` +
|
|
72
|
+
SourceFileLocationFormatter.formatDeclaration(arbitraryDeclaration));
|
|
73
|
+
}
|
|
74
|
+
astModule.cachedExportedEntities.set(exportedSymbol.name, astSymbol);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// The module is part of the local project, so do the full analysis
|
|
80
|
+
if (moduleSymbol.exports) {
|
|
81
|
+
// The "export * from 'module-name';" declarations are all attached to a single virtual symbol
|
|
82
|
+
// whose name is InternalSymbolName.ExportStar
|
|
83
|
+
const exportStarSymbol = moduleSymbol.exports.get(ts.InternalSymbolName.ExportStar);
|
|
84
|
+
if (exportStarSymbol) {
|
|
85
|
+
for (const exportStarDeclaration of exportStarSymbol.getDeclarations() || []) {
|
|
86
|
+
if (ts.isExportDeclaration(exportStarDeclaration)) {
|
|
87
|
+
const starExportedModule = this._fetchSpecifierAstModule(exportStarDeclaration, exportStarSymbol);
|
|
88
|
+
if (starExportedModule !== undefined) {
|
|
89
|
+
astModule.starExportedModules.add(starExportedModule);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// Ignore ExportDeclaration nodes that don't match the expected pattern
|
|
94
|
+
// TODO: Should we report a warning?
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return astModule;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves the symbol for the module corresponding to the ts.SourceFile that is being imported/exported.
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* The `module` keyword can be used to declare multiple TypeScript modules inside a single source file.
|
|
108
|
+
* (This is a deprecated construct and mainly used for typings such as `@types/node`.) In this situation,
|
|
109
|
+
* `moduleReference` helps us to fish out the correct module symbol.
|
|
110
|
+
*/
|
|
111
|
+
_getModuleSymbolFromSourceFile(sourceFile, moduleReference) {
|
|
112
|
+
const moduleSymbol = TypeScriptInternals.tryGetSymbolForDeclaration(sourceFile, this._typeChecker);
|
|
113
|
+
if (moduleSymbol !== undefined) {
|
|
114
|
+
// This is the normal case. The SourceFile acts is a module and has a symbol.
|
|
115
|
+
return moduleSymbol;
|
|
116
|
+
}
|
|
117
|
+
if (moduleReference !== undefined) {
|
|
118
|
+
// But there is also an elaborate case where the source file contains one or more "module" declarations,
|
|
119
|
+
// and our moduleReference took us to one of those.
|
|
120
|
+
// eslint-disable-next-line no-bitwise
|
|
121
|
+
if ((moduleReference.moduleSpecifierSymbol.flags & ts.SymbolFlags.Alias) !== 0) {
|
|
122
|
+
// Follow the import/export declaration to one hop the exported item inside the target module
|
|
123
|
+
let followedSymbol = TypeScriptInternals.getImmediateAliasedSymbol(moduleReference.moduleSpecifierSymbol, this._typeChecker);
|
|
124
|
+
if (followedSymbol === undefined) {
|
|
125
|
+
// This is a workaround for a compiler bug where getImmediateAliasedSymbol() sometimes returns undefined
|
|
126
|
+
followedSymbol = this._typeChecker.getAliasedSymbol(moduleReference.moduleSpecifierSymbol);
|
|
127
|
+
}
|
|
128
|
+
if (followedSymbol !== undefined && followedSymbol !== moduleReference.moduleSpecifierSymbol) {
|
|
129
|
+
// The parent of the exported symbol will be the module that we're importing from
|
|
130
|
+
const parent = TypeScriptInternals.getSymbolParent(followedSymbol);
|
|
131
|
+
if (parent !== undefined) {
|
|
132
|
+
// Make sure the thing we found is a module
|
|
133
|
+
// eslint-disable-next-line no-bitwise
|
|
134
|
+
if ((parent.flags & ts.SymbolFlags.ValueModule) !== 0) {
|
|
135
|
+
// Record that that this is an ambient module that can also be imported from
|
|
136
|
+
this._importableAmbientSourceFiles.add(sourceFile);
|
|
137
|
+
return parent;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
throw new InternalError('Unable to determine module for: ' + sourceFile.fileName);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Implementation of {@link AstSymbolTable.fetchAstModuleExportInfo}.
|
|
147
|
+
*/
|
|
148
|
+
fetchAstModuleExportInfo(entryPointAstModule) {
|
|
149
|
+
if (entryPointAstModule.isExternal) {
|
|
150
|
+
throw new Error('fetchAstModuleExportInfo() is not supported for external modules');
|
|
151
|
+
}
|
|
152
|
+
if (entryPointAstModule.astModuleExportInfo === undefined) {
|
|
153
|
+
const astModuleExportInfo = {
|
|
154
|
+
visitedAstModules: new Set(),
|
|
155
|
+
exportedLocalEntities: new Map(),
|
|
156
|
+
starExportedExternalModules: new Set()
|
|
157
|
+
};
|
|
158
|
+
this._collectAllExportsRecursive(astModuleExportInfo, entryPointAstModule);
|
|
159
|
+
entryPointAstModule.astModuleExportInfo = astModuleExportInfo;
|
|
160
|
+
}
|
|
161
|
+
return entryPointAstModule.astModuleExportInfo;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns true if the module specifier refers to an external package. Ignores packages listed in the
|
|
165
|
+
* "bundledPackages" setting from the api-extractor.json config file.
|
|
166
|
+
*/
|
|
167
|
+
_isExternalModulePath(importOrExportDeclaration, moduleSpecifier) {
|
|
168
|
+
var _a;
|
|
169
|
+
let specifier = ts.isImportTypeNode(importOrExportDeclaration)
|
|
170
|
+
? importOrExportDeclaration.argument
|
|
171
|
+
: importOrExportDeclaration.moduleSpecifier;
|
|
172
|
+
if (specifier && ts.isLiteralTypeNode(specifier)) {
|
|
173
|
+
specifier = specifier.literal;
|
|
174
|
+
}
|
|
175
|
+
const mode = specifier && ts.isStringLiteralLike(specifier)
|
|
176
|
+
? TypeScriptInternals.getModeForUsageLocation(importOrExportDeclaration.getSourceFile(), specifier, this._program.getCompilerOptions())
|
|
177
|
+
: undefined;
|
|
178
|
+
const resolvedModule = TypeScriptInternals.getResolvedModule(this._program, importOrExportDeclaration.getSourceFile(), moduleSpecifier, mode);
|
|
179
|
+
if (resolvedModule === undefined) {
|
|
180
|
+
// The TS compiler API `getResolvedModule` cannot resolve ambient modules. Thus, to match API Extractor's
|
|
181
|
+
// previous behavior, simply treat all ambient modules as external. This bug is tracked by
|
|
182
|
+
// https://github.com/microsoft/rushstack/issues/3335.
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
// Either something like `jquery` or `@microsoft/api-extractor`.
|
|
186
|
+
const packageName = (_a = resolvedModule.packageId) === null || _a === void 0 ? void 0 : _a.name;
|
|
187
|
+
if (packageName !== undefined && this._bundledPackageNames.has(packageName)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
if (resolvedModule.isExternalLibraryImport === undefined) {
|
|
191
|
+
// This presumably means the compiler couldn't figure out whether the module was external, but we're not
|
|
192
|
+
// sure how this can happen.
|
|
193
|
+
throw new InternalError(`Cannot determine whether the module ${JSON.stringify(moduleSpecifier)} is external\n` +
|
|
194
|
+
SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration));
|
|
195
|
+
}
|
|
196
|
+
return resolvedModule.isExternalLibraryImport;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Returns true if when we analyzed sourceFile, we found that it contains an "export=" statement that allows
|
|
200
|
+
* it to behave /either/ as an ambient module /or/ as a regular importable module. In this case,
|
|
201
|
+
* `AstSymbolTable._fetchAstSymbol()` will analyze its symbols even though `TypeScriptHelpers.isAmbient()`
|
|
202
|
+
* returns true.
|
|
203
|
+
*/
|
|
204
|
+
isImportableAmbientSourceFile(sourceFile) {
|
|
205
|
+
return this._importableAmbientSourceFiles.has(sourceFile);
|
|
206
|
+
}
|
|
207
|
+
_collectAllExportsRecursive(astModuleExportInfo, astModule) {
|
|
208
|
+
const { visitedAstModules, starExportedExternalModules, exportedLocalEntities } = astModuleExportInfo;
|
|
209
|
+
if (visitedAstModules.has(astModule)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
visitedAstModules.add(astModule);
|
|
213
|
+
if (astModule.isExternal) {
|
|
214
|
+
starExportedExternalModules.add(astModule);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// Fetch each of the explicit exports for this module
|
|
218
|
+
if (astModule.moduleSymbol.exports) {
|
|
219
|
+
astModule.moduleSymbol.exports.forEach((exportSymbol, exportName) => {
|
|
220
|
+
switch (exportName) {
|
|
221
|
+
case ts.InternalSymbolName.ExportStar:
|
|
222
|
+
case ts.InternalSymbolName.ExportEquals:
|
|
223
|
+
break;
|
|
224
|
+
default:
|
|
225
|
+
// Don't collect the "export default" symbol unless this is the entry point module
|
|
226
|
+
if (exportName !== ts.InternalSymbolName.Default || visitedAstModules.size === 1) {
|
|
227
|
+
if (!exportedLocalEntities.has(exportSymbol.name)) {
|
|
228
|
+
const astEntity = this._getExportOfAstModule(exportSymbol.name, astModule);
|
|
229
|
+
if (astEntity instanceof AstSymbol && !astEntity.isExternal) {
|
|
230
|
+
this._astSymbolTable.analyze(astEntity);
|
|
231
|
+
}
|
|
232
|
+
if (astEntity instanceof AstNamespaceImport && !astEntity.astModule.isExternal) {
|
|
233
|
+
this._astSymbolTable.analyze(astEntity);
|
|
234
|
+
}
|
|
235
|
+
exportedLocalEntities.set(exportSymbol.name, astEntity);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
for (const starExportedModule of astModule.starExportedModules) {
|
|
243
|
+
this._collectAllExportsRecursive(astModuleExportInfo, starExportedModule);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* For a given symbol (which was encountered in the specified sourceFile), this fetches the AstEntity that it
|
|
249
|
+
* refers to. For example, if a particular interface describes the return value of a function, this API can help
|
|
250
|
+
* us determine a TSDoc declaration reference for that symbol (if the symbol is exported).
|
|
251
|
+
*/
|
|
252
|
+
fetchReferencedAstEntity(symbol, referringModuleIsExternal) {
|
|
253
|
+
// eslint-disable-next-line no-bitwise
|
|
254
|
+
if ((symbol.flags & ts.SymbolFlags.FunctionScopedVariable) !== 0) {
|
|
255
|
+
// If a symbol refers back to part of its own definition, don't follow that rabbit hole
|
|
256
|
+
// Example:
|
|
257
|
+
//
|
|
258
|
+
// function f(x: number): typeof x {
|
|
259
|
+
// return 123;
|
|
260
|
+
// }
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
let current = symbol;
|
|
264
|
+
if (referringModuleIsExternal) {
|
|
265
|
+
current = TypeScriptHelpers.followAliases(symbol, this._typeChecker);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
for (;;) {
|
|
269
|
+
// Is this symbol an import/export that we need to follow to find the real declaration?
|
|
270
|
+
for (const declaration of current.declarations || []) {
|
|
271
|
+
let matchedAstEntity;
|
|
272
|
+
matchedAstEntity = this._tryMatchExportDeclaration(declaration, current);
|
|
273
|
+
if (matchedAstEntity !== undefined) {
|
|
274
|
+
return matchedAstEntity;
|
|
275
|
+
}
|
|
276
|
+
matchedAstEntity = this._tryMatchImportDeclaration(declaration, current);
|
|
277
|
+
if (matchedAstEntity !== undefined) {
|
|
278
|
+
return matchedAstEntity;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// eslint-disable-next-line no-bitwise
|
|
282
|
+
if (!(current.flags & ts.SymbolFlags.Alias)) {
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
const currentAlias = TypeScriptInternals.getImmediateAliasedSymbol(current, this._typeChecker);
|
|
286
|
+
// Stop if we reach the end of the chain
|
|
287
|
+
if (!currentAlias || currentAlias === current) {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
current = currentAlias;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// Otherwise, assume it is a normal declaration
|
|
294
|
+
const astSymbol = this._astSymbolTable.fetchAstSymbol({
|
|
295
|
+
followedSymbol: current,
|
|
296
|
+
isExternal: referringModuleIsExternal,
|
|
297
|
+
includeNominalAnalysis: false,
|
|
298
|
+
addIfMissing: true
|
|
299
|
+
});
|
|
300
|
+
return astSymbol;
|
|
301
|
+
}
|
|
302
|
+
fetchReferencedAstEntityFromImportTypeNode(node, referringModuleIsExternal) {
|
|
303
|
+
const externalModulePath = this._tryGetExternalModulePath(node);
|
|
304
|
+
if (externalModulePath) {
|
|
305
|
+
let exportName;
|
|
306
|
+
if (node.qualifier) {
|
|
307
|
+
// Example input:
|
|
308
|
+
// import('api-extractor-lib1-test').Lib1GenericType<number>
|
|
309
|
+
//
|
|
310
|
+
// Extracted qualifier:
|
|
311
|
+
// Lib1GenericType
|
|
312
|
+
exportName = node.qualifier.getText().trim();
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
// Example input:
|
|
316
|
+
// import('api-extractor-lib1-test')
|
|
317
|
+
//
|
|
318
|
+
// Extracted qualifier:
|
|
319
|
+
// apiExtractorLib1Test
|
|
320
|
+
exportName = SyntaxHelpers.makeCamelCaseIdentifier(externalModulePath);
|
|
321
|
+
}
|
|
322
|
+
return this._fetchAstImport(undefined, {
|
|
323
|
+
importKind: AstImportKind.ImportType,
|
|
324
|
+
exportName: exportName,
|
|
325
|
+
modulePath: externalModulePath,
|
|
326
|
+
isTypeOnly: false
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// Internal reference: AstSymbol
|
|
330
|
+
const rightMostToken = node.qualifier
|
|
331
|
+
? node.qualifier.kind === ts.SyntaxKind.QualifiedName
|
|
332
|
+
? node.qualifier.right
|
|
333
|
+
: node.qualifier
|
|
334
|
+
: node;
|
|
335
|
+
// There is no symbol property in a ImportTypeNode, obtain the associated export symbol
|
|
336
|
+
const exportSymbol = this._typeChecker.getSymbolAtLocation(rightMostToken);
|
|
337
|
+
if (!exportSymbol) {
|
|
338
|
+
throw new InternalError(`Symbol not found for identifier: ${node.getText()}\n` +
|
|
339
|
+
SourceFileLocationFormatter.formatDeclaration(node));
|
|
340
|
+
}
|
|
341
|
+
let followedSymbol = exportSymbol;
|
|
342
|
+
for (;;) {
|
|
343
|
+
const referencedAstEntity = this.fetchReferencedAstEntity(followedSymbol, referringModuleIsExternal);
|
|
344
|
+
if (referencedAstEntity) {
|
|
345
|
+
return referencedAstEntity;
|
|
346
|
+
}
|
|
347
|
+
const followedSymbolNode = followedSymbol.declarations && followedSymbol.declarations[0];
|
|
348
|
+
if (followedSymbolNode && followedSymbolNode.kind === ts.SyntaxKind.ImportType) {
|
|
349
|
+
return this.fetchReferencedAstEntityFromImportTypeNode(followedSymbolNode, referringModuleIsExternal);
|
|
350
|
+
}
|
|
351
|
+
// eslint-disable-next-line no-bitwise
|
|
352
|
+
if (!(followedSymbol.flags & ts.SymbolFlags.Alias)) {
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
const currentAlias = this._typeChecker.getAliasedSymbol(followedSymbol);
|
|
356
|
+
if (!currentAlias || currentAlias === followedSymbol) {
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
followedSymbol = currentAlias;
|
|
360
|
+
}
|
|
361
|
+
const astSymbol = this._astSymbolTable.fetchAstSymbol({
|
|
362
|
+
followedSymbol: followedSymbol,
|
|
363
|
+
isExternal: referringModuleIsExternal,
|
|
364
|
+
includeNominalAnalysis: false,
|
|
365
|
+
addIfMissing: true
|
|
366
|
+
});
|
|
367
|
+
return astSymbol;
|
|
368
|
+
}
|
|
369
|
+
_tryMatchExportDeclaration(declaration, declarationSymbol) {
|
|
370
|
+
const exportDeclaration = TypeScriptHelpers.findFirstParent(declaration, ts.SyntaxKind.ExportDeclaration);
|
|
371
|
+
if (exportDeclaration) {
|
|
372
|
+
let exportName = undefined;
|
|
373
|
+
if (declaration.kind === ts.SyntaxKind.ExportSpecifier) {
|
|
374
|
+
// EXAMPLE:
|
|
375
|
+
// "export { A } from './file-a';"
|
|
376
|
+
//
|
|
377
|
+
// ExportDeclaration:
|
|
378
|
+
// ExportKeyword: pre=[export] sep=[ ]
|
|
379
|
+
// NamedExports:
|
|
380
|
+
// FirstPunctuation: pre=[{] sep=[ ]
|
|
381
|
+
// SyntaxList:
|
|
382
|
+
// ExportSpecifier: <------------- declaration
|
|
383
|
+
// Identifier: pre=[A] sep=[ ]
|
|
384
|
+
// CloseBraceToken: pre=[}] sep=[ ]
|
|
385
|
+
// FromKeyword: pre=[from] sep=[ ]
|
|
386
|
+
// StringLiteral: pre=['./file-a']
|
|
387
|
+
// SemicolonToken: pre=[;]
|
|
388
|
+
// Example: " ExportName as RenamedName"
|
|
389
|
+
const exportSpecifier = declaration;
|
|
390
|
+
exportName = (exportSpecifier.propertyName || exportSpecifier.name).getText().trim();
|
|
391
|
+
}
|
|
392
|
+
else if (declaration.kind === ts.SyntaxKind.NamespaceExport) {
|
|
393
|
+
// EXAMPLE:
|
|
394
|
+
// "export * as theLib from 'the-lib';"
|
|
395
|
+
//
|
|
396
|
+
// ExportDeclaration:
|
|
397
|
+
// ExportKeyword: pre=[export] sep=[ ]
|
|
398
|
+
// NamespaceExport:
|
|
399
|
+
// AsteriskToken: pre=[*] sep=[ ]
|
|
400
|
+
// AsKeyword: pre=[as] sep=[ ]
|
|
401
|
+
// Identifier: pre=[theLib] sep=[ ]
|
|
402
|
+
// FromKeyword: pre=[from] sep=[ ]
|
|
403
|
+
// StringLiteral: pre=['the-lib']
|
|
404
|
+
// SemicolonToken: pre=[;]
|
|
405
|
+
// Issue tracking this feature: https://github.com/microsoft/rushstack/issues/2780
|
|
406
|
+
const astModule = this._fetchSpecifierAstModule(exportDeclaration, declarationSymbol);
|
|
407
|
+
return this._getAstNamespaceExport(astModule, declarationSymbol, declaration);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
throw new InternalError(`Unimplemented export declaration kind: ${declaration.getText()}\n` +
|
|
411
|
+
SourceFileLocationFormatter.formatDeclaration(declaration));
|
|
412
|
+
}
|
|
413
|
+
// Ignore "export { A }" without a module specifier
|
|
414
|
+
if (exportDeclaration.moduleSpecifier) {
|
|
415
|
+
const externalModulePath = this._tryGetExternalModulePath(exportDeclaration);
|
|
416
|
+
if (externalModulePath !== undefined) {
|
|
417
|
+
return this._fetchAstImport(declarationSymbol, {
|
|
418
|
+
importKind: AstImportKind.NamedImport,
|
|
419
|
+
modulePath: externalModulePath,
|
|
420
|
+
exportName: exportName,
|
|
421
|
+
isTypeOnly: false
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
return this._getExportOfSpecifierAstModule(exportName, exportDeclaration, declarationSymbol);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
_getAstNamespaceExport(astModule, declarationSymbol, declaration) {
|
|
430
|
+
const imoprtNamespace = this._getAstNamespaceImport(astModule, declarationSymbol, declaration);
|
|
431
|
+
return new AstNamespaceExport({
|
|
432
|
+
namespaceName: imoprtNamespace.localName,
|
|
433
|
+
astModule: astModule,
|
|
434
|
+
declaration,
|
|
435
|
+
symbol: declarationSymbol
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
_tryMatchImportDeclaration(declaration, declarationSymbol) {
|
|
439
|
+
const importDeclaration = TypeScriptHelpers.findFirstParent(declaration, ts.SyntaxKind.ImportDeclaration);
|
|
440
|
+
if (importDeclaration) {
|
|
441
|
+
const externalModulePath = this._tryGetExternalModulePath(importDeclaration);
|
|
442
|
+
if (declaration.kind === ts.SyntaxKind.NamespaceImport) {
|
|
443
|
+
// EXAMPLE:
|
|
444
|
+
// "import * as theLib from 'the-lib';"
|
|
445
|
+
//
|
|
446
|
+
// ImportDeclaration:
|
|
447
|
+
// ImportKeyword: pre=[import] sep=[ ]
|
|
448
|
+
// ImportClause:
|
|
449
|
+
// NamespaceImport: <------------- declaration
|
|
450
|
+
// AsteriskToken: pre=[*] sep=[ ]
|
|
451
|
+
// AsKeyword: pre=[as] sep=[ ]
|
|
452
|
+
// Identifier: pre=[theLib] sep=[ ]
|
|
453
|
+
// FromKeyword: pre=[from] sep=[ ]
|
|
454
|
+
// StringLiteral: pre=['the-lib']
|
|
455
|
+
// SemicolonToken: pre=[;]
|
|
456
|
+
if (externalModulePath === undefined) {
|
|
457
|
+
const astModule = this._fetchSpecifierAstModule(importDeclaration, declarationSymbol);
|
|
458
|
+
return this._getAstNamespaceImport(astModule, declarationSymbol, declaration);
|
|
459
|
+
}
|
|
460
|
+
// Here importSymbol=undefined because {@inheritDoc} and such are not going to work correctly for
|
|
461
|
+
// a package or source file.
|
|
462
|
+
return this._fetchAstImport(undefined, {
|
|
463
|
+
importKind: AstImportKind.StarImport,
|
|
464
|
+
exportName: declarationSymbol.name,
|
|
465
|
+
modulePath: externalModulePath,
|
|
466
|
+
isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
if (declaration.kind === ts.SyntaxKind.ImportSpecifier) {
|
|
470
|
+
// EXAMPLE:
|
|
471
|
+
// "import { A, B } from 'the-lib';"
|
|
472
|
+
//
|
|
473
|
+
// ImportDeclaration:
|
|
474
|
+
// ImportKeyword: pre=[import] sep=[ ]
|
|
475
|
+
// ImportClause:
|
|
476
|
+
// NamedImports:
|
|
477
|
+
// FirstPunctuation: pre=[{] sep=[ ]
|
|
478
|
+
// SyntaxList:
|
|
479
|
+
// ImportSpecifier: <------------- declaration
|
|
480
|
+
// Identifier: pre=[A]
|
|
481
|
+
// CommaToken: pre=[,] sep=[ ]
|
|
482
|
+
// ImportSpecifier:
|
|
483
|
+
// Identifier: pre=[B] sep=[ ]
|
|
484
|
+
// CloseBraceToken: pre=[}] sep=[ ]
|
|
485
|
+
// FromKeyword: pre=[from] sep=[ ]
|
|
486
|
+
// StringLiteral: pre=['the-lib']
|
|
487
|
+
// SemicolonToken: pre=[;]
|
|
488
|
+
// Example: " ExportName as RenamedName"
|
|
489
|
+
const importSpecifier = declaration;
|
|
490
|
+
const exportName = (importSpecifier.propertyName || importSpecifier.name).getText().trim();
|
|
491
|
+
if (externalModulePath !== undefined) {
|
|
492
|
+
return this._fetchAstImport(declarationSymbol, {
|
|
493
|
+
importKind: AstImportKind.NamedImport,
|
|
494
|
+
modulePath: externalModulePath,
|
|
495
|
+
exportName: exportName,
|
|
496
|
+
isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return this._getExportOfSpecifierAstModule(exportName, importDeclaration, declarationSymbol);
|
|
500
|
+
}
|
|
501
|
+
else if (declaration.kind === ts.SyntaxKind.ImportClause) {
|
|
502
|
+
// EXAMPLE:
|
|
503
|
+
// "import A, { B } from './A';"
|
|
504
|
+
//
|
|
505
|
+
// ImportDeclaration:
|
|
506
|
+
// ImportKeyword: pre=[import] sep=[ ]
|
|
507
|
+
// ImportClause: <------------- declaration (referring to A)
|
|
508
|
+
// Identifier: pre=[A]
|
|
509
|
+
// CommaToken: pre=[,] sep=[ ]
|
|
510
|
+
// NamedImports:
|
|
511
|
+
// FirstPunctuation: pre=[{] sep=[ ]
|
|
512
|
+
// SyntaxList:
|
|
513
|
+
// ImportSpecifier:
|
|
514
|
+
// Identifier: pre=[B] sep=[ ]
|
|
515
|
+
// CloseBraceToken: pre=[}] sep=[ ]
|
|
516
|
+
// FromKeyword: pre=[from] sep=[ ]
|
|
517
|
+
// StringLiteral: pre=['./A']
|
|
518
|
+
// SemicolonToken: pre=[;]
|
|
519
|
+
const importClause = declaration;
|
|
520
|
+
const exportName = importClause.name
|
|
521
|
+
? importClause.name.getText().trim()
|
|
522
|
+
: ts.InternalSymbolName.Default;
|
|
523
|
+
if (externalModulePath !== undefined) {
|
|
524
|
+
return this._fetchAstImport(declarationSymbol, {
|
|
525
|
+
importKind: AstImportKind.DefaultImport,
|
|
526
|
+
modulePath: externalModulePath,
|
|
527
|
+
exportName,
|
|
528
|
+
isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
return this._getExportOfSpecifierAstModule(ts.InternalSymbolName.Default, importDeclaration, declarationSymbol);
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
throw new InternalError(`Unimplemented import declaration kind: ${declaration.getText()}\n` +
|
|
535
|
+
SourceFileLocationFormatter.formatDeclaration(declaration));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (ts.isImportEqualsDeclaration(declaration)) {
|
|
539
|
+
// EXAMPLE:
|
|
540
|
+
// import myLib = require('my-lib');
|
|
541
|
+
//
|
|
542
|
+
// ImportEqualsDeclaration:
|
|
543
|
+
// ImportKeyword: pre=[import] sep=[ ]
|
|
544
|
+
// Identifier: pre=[myLib] sep=[ ]
|
|
545
|
+
// FirstAssignment: pre=[=] sep=[ ]
|
|
546
|
+
// ExternalModuleReference:
|
|
547
|
+
// RequireKeyword: pre=[require]
|
|
548
|
+
// OpenParenToken: pre=[(]
|
|
549
|
+
// StringLiteral: pre=['my-lib']
|
|
550
|
+
// CloseParenToken: pre=[)]
|
|
551
|
+
// SemicolonToken: pre=[;]
|
|
552
|
+
if (ts.isExternalModuleReference(declaration.moduleReference)) {
|
|
553
|
+
if (ts.isStringLiteralLike(declaration.moduleReference.expression)) {
|
|
554
|
+
const variableName = TypeScriptInternals.getTextOfIdentifierOrLiteral(declaration.name);
|
|
555
|
+
const externalModuleName = TypeScriptInternals.getTextOfIdentifierOrLiteral(declaration.moduleReference.expression);
|
|
556
|
+
return this._fetchAstImport(declarationSymbol, {
|
|
557
|
+
importKind: AstImportKind.EqualsImport,
|
|
558
|
+
modulePath: externalModuleName,
|
|
559
|
+
exportName: variableName,
|
|
560
|
+
isTypeOnly: false
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
_getAstNamespaceImport(astModule, declarationSymbol, declaration) {
|
|
568
|
+
let namespaceImport = this._astNamespaceImportByModule.get(astModule);
|
|
569
|
+
if (namespaceImport === undefined) {
|
|
570
|
+
namespaceImport = new AstNamespaceImport({
|
|
571
|
+
namespaceName: declarationSymbol.name,
|
|
572
|
+
astModule: astModule,
|
|
573
|
+
declaration: declaration,
|
|
574
|
+
symbol: declarationSymbol
|
|
575
|
+
});
|
|
576
|
+
this._astNamespaceImportByModule.set(astModule, namespaceImport);
|
|
577
|
+
}
|
|
578
|
+
return namespaceImport;
|
|
579
|
+
}
|
|
580
|
+
static _getIsTypeOnly(importDeclaration) {
|
|
581
|
+
if (importDeclaration.importClause) {
|
|
582
|
+
return !!importDeclaration.importClause.isTypeOnly;
|
|
583
|
+
}
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
_getExportOfSpecifierAstModule(exportName, importOrExportDeclaration, exportSymbol) {
|
|
587
|
+
const specifierAstModule = this._fetchSpecifierAstModule(importOrExportDeclaration, exportSymbol);
|
|
588
|
+
const astEntity = this._getExportOfAstModule(exportName, specifierAstModule);
|
|
589
|
+
return astEntity;
|
|
590
|
+
}
|
|
591
|
+
_getExportOfAstModule(exportName, astModule) {
|
|
592
|
+
const visitedAstModules = new Set();
|
|
593
|
+
const astEntity = this._tryGetExportOfAstModule(exportName, astModule, visitedAstModules);
|
|
594
|
+
if (astEntity === undefined) {
|
|
595
|
+
throw new InternalError(`Unable to analyze the export ${JSON.stringify(exportName)} in\n` + astModule.sourceFile.fileName);
|
|
596
|
+
}
|
|
597
|
+
return astEntity;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Implementation of {@link AstSymbolTable.tryGetExportOfAstModule}.
|
|
601
|
+
*/
|
|
602
|
+
tryGetExportOfAstModule(exportName, astModule) {
|
|
603
|
+
const visitedAstModules = new Set();
|
|
604
|
+
return this._tryGetExportOfAstModule(exportName, astModule, visitedAstModules);
|
|
605
|
+
}
|
|
606
|
+
_tryGetExportOfAstModule(exportName, astModule, visitedAstModules) {
|
|
607
|
+
if (visitedAstModules.has(astModule)) {
|
|
608
|
+
return undefined;
|
|
609
|
+
}
|
|
610
|
+
visitedAstModules.add(astModule);
|
|
611
|
+
let astEntity = astModule.cachedExportedEntities.get(exportName);
|
|
612
|
+
if (astEntity !== undefined) {
|
|
613
|
+
return astEntity;
|
|
614
|
+
}
|
|
615
|
+
// Try the explicit exports
|
|
616
|
+
const escapedExportName = ts.escapeLeadingUnderscores(exportName);
|
|
617
|
+
if (astModule.moduleSymbol.exports) {
|
|
618
|
+
const exportSymbol = astModule.moduleSymbol.exports.get(escapedExportName);
|
|
619
|
+
if (exportSymbol) {
|
|
620
|
+
astEntity = this.fetchReferencedAstEntity(exportSymbol, astModule.isExternal);
|
|
621
|
+
if (astEntity !== undefined) {
|
|
622
|
+
astModule.cachedExportedEntities.set(exportName, astEntity); // cache for next time
|
|
623
|
+
return astEntity;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
// Try each of the star imports
|
|
628
|
+
for (const starExportedModule of astModule.starExportedModules) {
|
|
629
|
+
astEntity = this._tryGetExportOfAstModule(exportName, starExportedModule, visitedAstModules);
|
|
630
|
+
if (astEntity !== undefined) {
|
|
631
|
+
if (starExportedModule.externalModulePath !== undefined) {
|
|
632
|
+
// This entity was obtained from an external module, so return an AstImport instead
|
|
633
|
+
const astSymbol = astEntity;
|
|
634
|
+
return this._fetchAstImport(astSymbol.followedSymbol, {
|
|
635
|
+
importKind: AstImportKind.NamedImport,
|
|
636
|
+
modulePath: starExportedModule.externalModulePath,
|
|
637
|
+
exportName: exportName,
|
|
638
|
+
isTypeOnly: false
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
return astEntity;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return undefined;
|
|
645
|
+
}
|
|
646
|
+
_tryGetExternalModulePath(importOrExportDeclaration) {
|
|
647
|
+
const moduleSpecifier = this._getModuleSpecifier(importOrExportDeclaration);
|
|
648
|
+
if (this._isExternalModulePath(importOrExportDeclaration, moduleSpecifier)) {
|
|
649
|
+
return moduleSpecifier;
|
|
650
|
+
}
|
|
651
|
+
return undefined;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Given an ImportDeclaration of the form `export { X } from "___";`, this interprets the module specifier (`"___"`)
|
|
655
|
+
* and fetches the corresponding AstModule object.
|
|
656
|
+
*/
|
|
657
|
+
_fetchSpecifierAstModule(importOrExportDeclaration, exportSymbol) {
|
|
658
|
+
const moduleSpecifier = this._getModuleSpecifier(importOrExportDeclaration);
|
|
659
|
+
const mode = importOrExportDeclaration.moduleSpecifier &&
|
|
660
|
+
ts.isStringLiteralLike(importOrExportDeclaration.moduleSpecifier)
|
|
661
|
+
? TypeScriptInternals.getModeForUsageLocation(importOrExportDeclaration.getSourceFile(), importOrExportDeclaration.moduleSpecifier, this._program.getCompilerOptions())
|
|
662
|
+
: undefined;
|
|
663
|
+
const resolvedModule = TypeScriptInternals.getResolvedModule(this._program, importOrExportDeclaration.getSourceFile(), moduleSpecifier, mode);
|
|
664
|
+
if (resolvedModule === undefined) {
|
|
665
|
+
// Encountered in https://github.com/microsoft/rushstack/issues/1914.
|
|
666
|
+
//
|
|
667
|
+
// It's also possible for this to occur with ambient modules. However, in practice this doesn't happen
|
|
668
|
+
// as API Extractor treats all ambient modules as external per the logic in `_isExternalModulePath`, and
|
|
669
|
+
// thus this code path is never reached for ambient modules.
|
|
670
|
+
throw new InternalError(`getResolvedModule() could not resolve module name ${JSON.stringify(moduleSpecifier)}\n` +
|
|
671
|
+
SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration));
|
|
672
|
+
}
|
|
673
|
+
// Map the filename back to the corresponding SourceFile. This circuitous approach is needed because
|
|
674
|
+
// we have no way to access the compiler's internal resolveExternalModuleName() function
|
|
675
|
+
const moduleSourceFile = this._program.getSourceFile(resolvedModule.resolvedFileName);
|
|
676
|
+
if (!moduleSourceFile) {
|
|
677
|
+
// This should not happen, since getResolvedModule() specifically looks up names that the compiler
|
|
678
|
+
// found in export declarations for this source file
|
|
679
|
+
throw new InternalError(`getSourceFile() failed to locate ${JSON.stringify(resolvedModule.resolvedFileName)}\n` +
|
|
680
|
+
SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration));
|
|
681
|
+
}
|
|
682
|
+
const isExternal = this._isExternalModulePath(importOrExportDeclaration, moduleSpecifier);
|
|
683
|
+
const moduleReference = {
|
|
684
|
+
moduleSpecifier: moduleSpecifier,
|
|
685
|
+
moduleSpecifierSymbol: exportSymbol
|
|
686
|
+
};
|
|
687
|
+
const specifierAstModule = this.fetchAstModuleFromSourceFile(moduleSourceFile, moduleReference, isExternal);
|
|
688
|
+
return specifierAstModule;
|
|
689
|
+
}
|
|
690
|
+
_fetchAstImport(importSymbol, options) {
|
|
691
|
+
const key = AstImport.getKey(options);
|
|
692
|
+
let astImport = this._astImportsByKey.get(key);
|
|
693
|
+
if (!astImport) {
|
|
694
|
+
astImport = new AstImport(options);
|
|
695
|
+
this._astImportsByKey.set(key, astImport);
|
|
696
|
+
if (importSymbol) {
|
|
697
|
+
const followedSymbol = TypeScriptHelpers.followAliases(importSymbol, this._typeChecker);
|
|
698
|
+
astImport.astSymbol = this._astSymbolTable.fetchAstSymbol({
|
|
699
|
+
followedSymbol: followedSymbol,
|
|
700
|
+
isExternal: true,
|
|
701
|
+
includeNominalAnalysis: false,
|
|
702
|
+
addIfMissing: true
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
// If we encounter at least one import that does not use the type-only form,
|
|
708
|
+
// then the .d.ts rollup will NOT use "import type".
|
|
709
|
+
if (!options.isTypeOnly) {
|
|
710
|
+
astImport.isTypeOnlyEverywhere = false;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return astImport;
|
|
714
|
+
}
|
|
715
|
+
_getModuleSpecifier(importOrExportDeclaration) {
|
|
716
|
+
// The name of the module, which could be like "./SomeLocalFile' or like 'external-package/entry/point'
|
|
717
|
+
const moduleSpecifier = TypeScriptHelpers.getModuleSpecifier(importOrExportDeclaration);
|
|
718
|
+
if (!moduleSpecifier) {
|
|
719
|
+
throw new InternalError('Unable to parse module specifier\n' +
|
|
720
|
+
SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration));
|
|
721
|
+
}
|
|
722
|
+
return moduleSpecifier;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
//# sourceMappingURL=ExportAnalyzer.js.map
|