{"id":"fa04d1e4d004a1cb","repo":"jestjs/jest","slug":"api-extractor-completed-with-extractorresult-err","errorCode":null,"errorMessage":"API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings","messagePattern":"API Extractor completed with (.+?) errors and (.+?) warnings","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/bundleTs.mjs","lineNumber":156,"sourceCode":"        additionalEntryPoints: packagesToBundle.map(({pkg, packageDir}) =>\n          path.resolve(packageDir, pkg.types),\n        ),\n        typescriptCompilerFolder,\n      });\n    }\n\n    const extractorResult = Extractor.invoke(extractorConfig, {\n      compilerState,\n      localBuild: true,\n      showVerboseMessages: true,\n      typescriptCompilerFolder,\n    });\n\n    if (!extractorResult.succeeded || extractorResult.warningCount > 0) {\n      console.error(\n        chalk.inverse.red(' Unable to extract TypeScript definition files '),\n      );\n      throw new Error(\n        `API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings`,\n      );\n    }\n\n    const filepath = extractorResult.extractorConfig.untrimmedFilePath;\n\n    let definitionFile = await fs.promises.readFile(filepath, 'utf8');\n\n    await rimraf(path.resolve(packageDir, 'build/**/*.d.ts'), {glob: true});\n    await fs.promises.rm(path.resolve(packageDir, 'dist/'), {\n      force: true,\n      recursive: true,\n    });\n    // this is invalid now, so remove it to not confuse `tsc`\n    await fs.promises.rm(path.resolve(packageDir, 'tsconfig.tsbuildinfo'), {\n      force: true,\n      recursive: true,\n    });","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/scripts/bundleTs.mjs#L138-L174","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","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."],"exampleFix":"// before (src/index.ts) — exported type missing release tag\nexport type Options = { ... };\n// after\n/** @public */\nexport type Options = { ... };","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = Extractor.invoke(extractorConfig, { compilerState, localBuild: true, showVerboseMessages: true });\n  if (!result.succeeded || result.warningCount > 0) {\n    throw new Error(`API Extractor: ${result.errorCount} errors, ${result.warningCount} warnings`);\n  }\n} catch (err) {\n  console.error('API Extractor failed; review ae-* diagnostics above.');\n  console.error(err.message);\n  // re-surface so CI fails, but after dumping context for triage\n  throw err;\n}","preventionTips":["Tag every exported API member with @public or @internal so API Extractor's release-tag rules pass.","Keep the api-report snapshot committed; update it deliberately when the public API changes.","Run scripts/bundleTs.mjs locally before pushing to catch ae-* diagnostics early.","Avoid exporting types whose dependencies aren't themselves exported (causes ae-unresolved-link)."],"tags":["build","typescript","api-extractor","declaration-files","dts-bundle","monorepo"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}