diff --git a/.changeset/soft-lies-watch.md b/.changeset/soft-lies-watch.md new file mode 100644 index 0000000000..6e38e0f1fa --- /dev/null +++ b/.changeset/soft-lies-watch.md @@ -0,0 +1,5 @@ +--- +'@backstage/repo-tools': patch +--- + +Include asset-types.d.ts while running the api report command diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index 46f4ea984b..e6f1ffb101 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -16,7 +16,6 @@ /* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-restricted-imports */ - import { resolve as resolvePath, relative as relativePath, @@ -66,7 +65,6 @@ import { import { IMarkdownEmitterContext } from '@microsoft/api-documenter/lib/markdown/MarkdownEmitter'; import { AstDeclaration } from '@microsoft/api-extractor/lib/analyzer/AstDeclaration'; import { paths as cliPaths } from '../../lib/paths'; - import minimatch from 'minimatch'; const tmpDir = cliPaths.resolveTargetRoot( @@ -228,13 +226,25 @@ export async function createTemporaryTsConfig(includedPackageDirs: string[]) { fs.removeSync(path); }); + let assetTypeFile: string[] = []; + + try { + assetTypeFile = [ + require.resolve('@backstage/cli/asset-types/asset-types.d.ts'), + ]; + } catch { + /** ignore */ + } + await fs.writeJson(path, { extends: './tsconfig.json', include: [ // These two contain global definitions that are needed for stable API report generation - 'packages/cli/asset-types/asset-types.d.ts', + ...assetTypeFile, ...includedPackageDirs.map(dir => join(dir, 'src')), ], + // we don't exclude node_modules so that we can use the asset-types.d.ts file + exclude: [], }); return path;