# @types/which

> TypeScript definitions for which

Latest version **3.0.4** (published 2024-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/which
pnpm add @types/which
yarn add @types/which
bun add @types/which
```

## Health

**Score 45/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2024-05-30 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51429 |
| Maintainers | types |

## Links

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

## Recent versions

- 3.0.4 (latest) — 2024-05-30
- 3.0.3 (ts4.6) — 2023-11-21
- 3.0.0 (ts4.4) — 2023-03-22
- 2.0.2 (ts4.2) — 2023-02-14
- 2.0.1 (ts4.1) — 2021-07-02
- 2.0.0 (ts3.5) — 2020-12-23
- 1.3.2 (ts2.1) — 2019-10-09
- 3.0.2 — 2023-11-07
- 3.0.1 — 2023-10-18
- 1.3.1 — 2018-01-03
- 1.3.0 — 2017-12-28
- 1.0.28 — 2016-09-19
- 1.0.27 — 2016-07-14
- 1.0.26-alpha — 2016-07-08
- 1.0.25-alpha — 2016-07-04
- … 7 more at https://npm.io/package/@types/which/versions

## README

# Installation
> `npm install --save @types/which`

# Summary
This package contains type definitions for which (https://github.com/isaacs/node-which).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/which.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/which/index.d.ts)
````ts
/** Finds all instances of a specified executable in the PATH environment variable */

type AppendNullIfNothrow<TOptions, TRet> = TOptions extends { nothrow: infer TVal }
    // nothrow is specified
    ? TVal extends false
        // TVal is false
        ? TRet
        // TVal is boolean or true
    : TRet | null
    // nothrow not specified
    : TRet;

type TransformToArrayIfAll<TOptions, TRet> = TOptions extends { all: infer TVal }
    // all is specified
    ? TVal extends true
        // TVal is true
        ? readonly TRet[]
    : TVal extends false
        // TVal is false
        ? TRet
        // TVal is boolean
    : readonly TRet[] | TRet
    // all not specified
    : TRet;

type ReturnType<TOptions> = AppendNullIfNothrow<TOptions, TransformToArrayIfAll<TOptions, string>>;

type Exact<T, U extends T> = {
    [Key in keyof U]: Key extends keyof T ? U[Key]
        : never;
};

declare function which<TOptions extends which.Options>(
    cmd: string,
    options?: Exact<which.Options, TOptions>,
): Promise<ReturnType<Exact<which.Options, TOptions>>>;

declare namespace which {
    /** Finds all instances of a specified executable in the PATH environment variable */
    function sync<TOptions extends Options>(
        cmd: string,
        options?: Exact<Options, TOptions>,
    ): ReturnType<Exact<Options, TOptions>>;

    /** Options for which() API */
    interface Options {
        /** If true, return all matches, instead of just the first one. Note that this means the function returns an array of strings instead of a single string. */
        all?: boolean | undefined;
        /** Use instead of the PATH environment variable. */
        path?: string | undefined;
        /** Use instead of the PATHEXT environment variable. */
        pathExt?: string | undefined;
        /** Use instead of the platform's native path separator. */
        delimiter?: string | undefined;
        /** If true, returns null when not found */
        nothrow?: boolean | undefined;
    }
}

export = which;

````

### Additional Details
 * Last updated: Thu, 30 May 2024 17:35:42 GMT
 * Dependencies: none

# Credits
These definitions were written by [vvakame](https://github.com/vvakame), [cspotcode](https://github.com/cspotcode), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).

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