Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/api-extractor/src/api/CompilerState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ export class CompilerState {
);
}

// Delete outDir and declarationDir to prevent TypeScript from redirecting self-package
// imports to source files. When these options are set, TypeScript's module resolution
// tries to map output .d.ts files back to their source .ts files to avoid analyzing
// build outputs during compilation. However, API Extractor specifically wants to analyze
// the .d.ts build artifacts, not the source files. Since API Extractor doesn't emit any
// files, these options are unnecessary and interfere with correct module resolution.
delete commandLine.options.outDir;
delete commandLine.options.declarationDir;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very insightful! I've seen this problem before, but I didn't realize the import analysis was affected by outDir and declarationDir.


const inputFilePaths: string[] = commandLine.fileNames.concat(extractorConfig.mainEntryPointFilePath);
if (options && options.additionalEntryPoints) {
inputFilePaths.push(...options.additionalEntryPoints);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/api-extractor",
"comment": "Fix self-package import resolution by removing outDir/declarationDir from compiler options",
"type": "patch"
}
],
"packageName": "@microsoft/api-extractor"
}
Loading