diff --git a/apps/api-extractor/src/generators/DtsRollupGenerator.ts b/apps/api-extractor/src/generators/DtsRollupGenerator.ts index 7a9e9fb5550..2de36342800 100644 --- a/apps/api-extractor/src/generators/DtsRollupGenerator.ts +++ b/apps/api-extractor/src/generators/DtsRollupGenerator.ts @@ -105,18 +105,12 @@ export class DtsRollupGenerator { // Emit the imports for (const entity of collector.entities) { if (entity.astEntity instanceof AstImport) { + // Note: it isn't valid to trim imports based on their release tags. + // E.g. class Foo (`@public`) extends interface Bar (`@beta`) from some external library. + // API-Extractor cannot trim `import { Bar } from "externa-library"` when generating its public rollup, + // or the export of `Foo` would include a broken reference to `Bar`. const astImport: AstImport = entity.astEntity; - - // For example, if the imported API comes from an external package that supports AEDoc, - // and it was marked as `@internal`, then don't emit it. - const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astImport); - const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata - ? symbolMetadata.maxEffectiveReleaseTag - : ReleaseTag.None; - - if (this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) { - DtsEmitHelpers.emitImport(writer, entity, astImport); - } + DtsEmitHelpers.emitImport(writer, entity, astImport); } } writer.ensureSkippedLine(); diff --git a/common/changes/@microsoft/api-extractor/dont-trim-imports_2024-02-21-00-32.json b/common/changes/@microsoft/api-extractor/dont-trim-imports_2024-02-21-00-32.json new file mode 100644 index 00000000000..36f903e40d7 --- /dev/null +++ b/common/changes/@microsoft/api-extractor/dont-trim-imports_2024-02-21-00-32.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/api-extractor", + "comment": "Fix an issue where imports were trimmed from external packages based when generating .d.ts rollups", + "type": "patch" + } + ], + "packageName": "@microsoft/api-extractor" +} \ No newline at end of file