@types/istanbul-lib-instrument
Version:
TypeScript definitions for istanbul-lib-instrument
91 lines (71 loc) • 2.7 kB
Markdown
# Installation
> `npm install --save @types/istanbul-lib-instrument`
# Summary
This package contains type definitions for istanbul-lib-instrument (https://istanbul.js.org).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-instrument.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-instrument/index.d.ts)
````ts
import * as babelTypes from "babel-types";
import { FileCoverage, FileCoverageData, Range } from "istanbul-lib-coverage";
import { RawSourceMap } from "source-map";
export interface InstrumenterOptions {
coverageVariable: string;
preserveComments: boolean;
compact: boolean;
esModules: boolean;
autoWrap: boolean;
produceSourceMap: boolean;
sourceMapUrlCallback(filename: string, url: string): void;
debug: boolean;
}
export type InstrumenterCallback = (error: Error | null, code: string) => void;
export class Instrumenter {
fileCoverage: FileCoverage;
sourceMap: RawSourceMap | null;
opts: InstrumenterOptions;
constructor(options?: Partial<InstrumenterOptions>);
normalizeOpts(options?: Partial<InstrumenterOptions>): InstrumenterOptions;
instrumentSync(
code: string,
filename: string,
inputSourceMap?: RawSourceMap,
): string;
instrument(
code: string,
filenameOrCallback: string | InstrumenterCallback,
callback?: InstrumenterCallback,
inputSourceMap?: RawSourceMap,
): void;
lastFileCoverage(): FileCoverageData;
lastSourceMap(): RawSourceMap;
}
export function createInstrumenter(
options?: Partial<InstrumenterOptions>,
): Instrumenter;
export interface InitialCoverage {
path: string;
hash: string;
gcv: any;
coverageData: any;
}
export function readInitialCoverage(code: string): InitialCoverage;
export interface Visitor {
enter(path: string): void;
exit(path: string): { fileCoverage: FileCoverage; sourceMappingURL: string };
}
export interface VisitorOptions {
coverageVariable: string;
inputSourceMap: RawSourceMap;
}
export function programVisitor(
types: typeof babelTypes,
sourceFilePath?: string,
opts?: Partial<VisitorOptions>,
): Visitor;
````
### Additional Details
* Last updated: Tue, 07 Nov 2023 03:09:37 GMT
* Dependencies: [@types/babel-types](https://npmjs.com/package/@types/babel-types), [@types/istanbul-lib-coverage](https://npmjs.com/package/@types/istanbul-lib-coverage), [source-map](https://npmjs.com/package/source-map)
# Credits
These definitions were written by [Jason Cheatham](https://github.com/jason0x43).