Skip to content

Commit 2e5fe72

Browse files
a-orenclaude
andauthored
fix: add JSDoc overloads to stackAnalysisBatch for type narrowing (#502)
Consumers can now get precise return types based on html and batchMetadata arguments, matching the pattern used by stackAnalysis and imageAnalysis. Related: fabric8-analytics/fabric8-analytics-vscode-extension#889 (comment) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 58200d2 commit 2e5fe72

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,49 @@ function batchError(message, wantMetadata, metadata) {
447447
return err
448448
}
449449

450+
/**
451+
* @overload
452+
* @param {string} workspaceRoot
453+
* @param {true} html
454+
* @param {Options & { batchMetadata: true }} opts
455+
* @returns {Promise<{ analysis: string, metadata: BatchAnalysisMetadata }>}
456+
* @throws {Error}
457+
*/
458+
459+
/**
460+
* @overload
461+
* @param {string} workspaceRoot
462+
* @param {true} html
463+
* @param {Options & { batchMetadata?: false }} [opts={}]
464+
* @returns {Promise<string>}
465+
* @throws {Error}
466+
*/
467+
468+
/**
469+
* @overload
470+
* @param {string} workspaceRoot
471+
* @param {false} html
472+
* @param {Options & { batchMetadata: true }} opts
473+
* @returns {Promise<{ analysis: Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>, metadata: BatchAnalysisMetadata }>}
474+
* @throws {Error}
475+
*/
476+
477+
/**
478+
* @overload
479+
* @param {string} workspaceRoot
480+
* @param {false} html
481+
* @param {Options & { batchMetadata?: false }} [opts={}]
482+
* @returns {Promise<Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
483+
* @throws {Error}
484+
*/
485+
450486
/**
451487
* Get stack analysis for all workspace packages/crates (batch).
452488
* Detects ecosystem from workspace root: Cargo (Cargo.toml + Cargo.lock) or JS/TS (package.json + lock file).
453489
* SBOMs are generated in parallel (see `batchConcurrency`) unless `continueOnError: false` (fail-fast sequential).
454490
* With `opts.batchMetadata` / `TRUSTIFY_DA_BATCH_METADATA`, returns `{ analysis, metadata }` including validation and SBOM errors.
455491
*
492+
* @overload
456493
* @param {string} workspaceRoot - Path to workspace root (containing lock file and workspace config)
457494
* @param {boolean} [html=false] - true returns HTML, false returns JSON report
458495
* @param {Options} [opts={}] - `batchConcurrency`, discovery ignores, `continueOnError` (default true), `batchMetadata` (default false)

0 commit comments

Comments
 (0)