jestjs/jest · error · Error

API Extractor completed with ${extractorResult.errorCount} e

Error message

API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings

What it means

scripts/bundleTs.mjs runs Microsoft API Extractor (Extractor.invoke) to roll up a package's .d.ts into a single bundled declaration file. At bundleTs.mjs:152-158, if extractorResult.succeeded is false OR warningCount > 0, it throws an Error summarizing errorCount and warningCount. API Extractor enforces API consistency, export coverage, and ae-* release-tagging rules; any error or warning fails the bundle.

Source

Thrown at scripts/bundleTs.mjs:156

        additionalEntryPoints: packagesToBundle.map(({pkg, packageDir}) =>
          path.resolve(packageDir, pkg.types),
        ),
        typescriptCompilerFolder,
      });
    }

    const extractorResult = Extractor.invoke(extractorConfig, {
      compilerState,
      localBuild: true,
      showVerboseMessages: true,
      typescriptCompilerFolder,
    });

    if (!extractorResult.succeeded || extractorResult.warningCount > 0) {
      console.error(
        chalk.inverse.red(' Unable to extract TypeScript definition files '),
      );
      throw new Error(
        `API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings`,
      );
    }

    const filepath = extractorResult.extractorConfig.untrimmedFilePath;

    let definitionFile = await fs.promises.readFile(filepath, 'utf8');

    await rimraf(path.resolve(packageDir, 'build/**/*.d.ts'), {glob: true});
    await fs.promises.rm(path.resolve(packageDir, 'dist/'), {
      force: true,
      recursive: true,
    });
    // this is invalid now, so remove it to not confuse `tsc`
    await fs.promises.rm(path.resolve(packageDir, 'tsconfig.tsbuildinfo'), {
      force: true,
      recursive: true,
    });

View on GitHub (pinned to f49721c78e)

Solutions

  1. Re-run with showVerboseMessages (already on) and read the full API Extractor diagnostics above the throw to find the exact .d.ts and ae-* code.
  2. Fix each diagnostic: add @public/@internal JSDoc tags to exported API, export referenced types, or update the api-report snapshot if the change is intentional.
  3. If warnings are expected/acceptable only as a last resort, relax the rule in api-extractor.json — but the script treats warningCount > 0 as failure, so prefer fixing the source.

Example fix

// before (src/index.ts) — exported type missing release tag
export type Options = { ... };
// after
/** @public */
export type Options = { ... };
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const result = Extractor.invoke(extractorConfig, { compilerState, localBuild: true, showVerboseMessages: true });
  if (!result.succeeded || result.warningCount > 0) {
    throw new Error(`API Extractor: ${result.errorCount} errors, ${result.warningCount} warnings`);
  }
} catch (err) {
  console.error('API Extractor failed; review ae-* diagnostics above.');
  console.error(err.message);
  // re-surface so CI fails, but after dumping context for triage
  throw err;
}

Prevention

When it happens

Trigger: Running scripts/bundleTs.mjs when the .d.ts bundle has unresolved API Extractor diagnostics: unexported public types referenced by exported ones (ae-missing-release-tag), missing @public/@internal tags, broken references, or config (api-report/config) mismatches.

Common situations: Adding a new exported type without a release tag (@public/@internal); changing the public API surface in a way API Extractor's saved report doesn't match; upgrading @microsoft/api-extractor with stricter defaults; pointing extractorConfig at stale entry points.

Related errors


AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03). Data as JSON: /data/errors/fa04d1e4d004a1cb.json. Report an issue: GitHub.