Skip to content

Commit

Permalink
types: add api types
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-michelet committed Apr 12, 2024
1 parent 4bf8f8a commit 2274288
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {
AstAnalyser,
AstAnalyserOptions,

EntryFilesAnalyser,
EntryFilesAnalyserOptions,

SourceParser,
runASTAnalysis,
runASTAnalysisOnFile,
Expand All @@ -23,6 +28,9 @@ declare const warnings: Record<WarningName, Pick<WarningDefault, "experimental"
export {
warnings,
AstAnalyser,
AstAnalyserOptions,
EntryFilesAnalyser,
EntryFilesAnalyserOptions,
SourceParser,
runASTAnalysis,
runASTAnalysisOnFile,
Expand Down
4 changes: 2 additions & 2 deletions src/EntryFilesAnalyser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export class EntryFilesAnalyser {
}

/**
* Analyzes a set of entry files asynchronously, yielding analysis reports.
* Asynchronously analyze a set of entry files yielding analysis reports.
*
* @param {(string | URL)[]} entryFiles
* @yields {Object} - Yields an object containing the analysis results for each file.
* @yields {Object} - Yields an object containing the analysis report for each file.
*/
async* analyse(entryFiles) {
this.analyzedDeps = new Set();
Expand Down
17 changes: 17 additions & 0 deletions types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { Statement } from "meriyah/dist/src/estree.js";

export {
AstAnalyser,
EntryFilesAnalyser,
SourceParser,
runASTAnalysis,
runASTAnalysisOnFile,

AstAnalyserOptions,
EntryFilesAnalyserOptions,
RuntimeOptions,
RuntimeFileOptions,

Expand Down Expand Up @@ -101,5 +104,19 @@ declare class AstAnalyser {
analyzeFile(pathToFile: string, options?: RuntimeFileOptions): Promise<ReportOnFile>;
}

interface EntryFilesAnalyserOptions {
astAnalyzer?: AstAnalyser;
loadExtensions?: (defaults: string[]) => string[];
}

declare class EntryFilesAnalyser {
constructor(options?: EntryFilesAnalyserOptions);

/**
* Asynchronously analyze a set of entry files yielding analysis reports.
*/
analyse(entryFiles: (string | URL)[]): AsyncGenerator<ReportOnFile & { url: string }>;
}

declare function runASTAnalysis(str: string, options?: RuntimeOptions & AstAnalyserOptions): Report;
declare function runASTAnalysisOnFile(pathToFile: string, options?: RuntimeFileOptions & AstAnalyserOptions): Promise<ReportOnFile>;

0 comments on commit 2274288

Please sign in to comment.