# @types/istanbul-lib-instrument

> TypeScript definitions for istanbul-lib-instrument

Latest version **1.7.8** (published 2025-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/istanbul-lib-instrument
pnpm add @types/istanbul-lib-instrument
yarn add @types/istanbul-lib-instrument
bun add @types/istanbul-lib-instrument
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.7.8 |
| Published | 2025-08-06 |
| First published | 2017-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51446 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/istanbul-lib-instrument
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-instrument
- npm.io page: https://npm.io/package/@types/istanbul-lib-instrument

## Dependencies (4)

- [source-map](https://npm.io/package/source-map.md) ^0.6.1
- [@types/babel-types](https://npm.io/package/@types/babel-types.md) *
- [@types/babel-generator](https://npm.io/package/@types/babel-generator.md) *
- [@types/istanbul-lib-coverage](https://npm.io/package/@types/istanbul-lib-coverage.md) *

## Recent versions

- 1.7.8 (latest) — 2025-08-06
- 1.7.7 (ts4.5) — 2023-11-07
- 1.7.4 (ts3.0) — 2020-05-15
- 1.7.3 (ts2.8) — 2019-04-25
- 1.7.1 (ts2.4) — 2018-01-02
- 1.7.6 — 2023-10-18
- 1.7.5 — 2023-09-26
- 1.7.2 — 2018-06-12
- 1.7.0 — 2017-08-31

## README

# 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 { GeneratorOptions } from "babel-generator";
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;
    coverageGlobalScope?: string;
    coverageGlobalScopeFunc?: boolean;
    ignoreClassMethods?: string[];
    parserPlugins?: any[];
    generatorOpts?: GeneratorOptions;
}

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: Wed, 06 Aug 2025 00:05:03 GMT
 * Dependencies: [@types/babel-generator](https://npmjs.com/package/@types/babel-generator), [@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).

---
_Source: https://npm.io/package/@types/istanbul-lib-instrument · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
