# @types/loader-utils

> TypeScript definitions for loader-utils

Latest version **3.0.0** (published 2025-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/loader-utils
pnpm add @types/loader-utils
yarn add @types/loader-utils
bun add @types/loader-utils
```

## 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 | 3.0.0 |
| Published | 2025-08-22 |
| First published | 2017-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51428 |
| Maintainers | types |

## Links

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

## Dependencies (2)

- [webpack](https://npm.io/package/webpack.md) ^5
- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 3.0.0 (latest) — 2025-08-22
- 2.0.6 (ts4.6) — 2023-11-07
- 2.0.4 (ts4.3) — 2023-08-30
- 2.0.3 (ts3.9) — 2021-07-06
- 2.0.1 (ts3.0) — 2020-06-16
- 1.1.3 (ts2.7) — 2018-03-10
- 1.1.2 (ts2.2) — 2018-02-13
- 1.1.1 (ts2.1) — 2017-12-28
- 1.1.9 — 2023-11-07
- 1.1.8 — 2023-10-18
- 2.0.5 — 2023-10-18
- 1.1.7 — 2023-08-30
- 1.1.6 — 2021-07-06
- 1.1.5 — 2021-03-25
- 2.0.2 — 2021-03-25
- … 3 more at https://npm.io/package/@types/loader-utils/versions

## README

# Installation
> `npm install --save @types/loader-utils`

# Summary
This package contains type definitions for loader-utils (https://github.com/webpack/loader-utils#readme).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/loader-utils.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/loader-utils/index.d.ts)
````ts
/// <reference types="node" />

import { LoaderContext } from "webpack";

export type Readonly<T> = {
    readonly [P in keyof T]: T[P];
};

export interface LoaderInterpolateOption {
    customInterpolateName?: typeof interpolateName;
}

export interface InterpolateOption {
    context?: string | undefined;
    content?: string | Buffer | undefined;
    regExp?: string | RegExp | undefined;
}

export interface OptionObject {
    [key: string]: null | false | true | string;
}

export type InterpolateNameType = string | ((resourcePath: string, resourceQuery?: string) => string);

export type HashType = "xxhash64" | "sha1" | "md4" | "native-md4" | "md5" | "sha256" | "sha512";

export type DigestType =
    | "hex"
    | "base26"
    | "base32"
    | "base36"
    | "base49"
    | "base52"
    | "base58"
    | "base62"
    | "base64"
    | "base64safe";
/**
 * {@link https://https://github.com/webpack/loader-utils#urltorequest}
 */
export function isUrlRequest(url: string, root?: string): boolean;

/**
 * Converts some resource URL to a webpack module request.
 * {@link https://github.com/webpack/loader-utils#urltorequest}
 */
export function urlToRequest(url: string, root?: string): string;

/**
 * Interpolates a filename template using multiple placeholders and/or a regular expression.
 * The template and regular expression are set as query params called name and regExp on the current loader's context.
 * {@link https://github.com/webpack/loader-utils#interpolatename}
 */
export function interpolateName(
    loaderContext: LoaderContext<LoaderInterpolateOption>,
    name: InterpolateNameType,
    options?: InterpolateOption,
): string;

/**
 * @param buffer the content that should be hashed
 * @param [hashType='xxhash64'] one of `xxhash64`, `sha1`, `md4`, `md5`, `sha256`, `sha512` or any other node.js supported hash type
 * @param [digestType='hex'] one of `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`, `base64safe`
 * @param [maxLength=9999] the maximum length in chars
 * {@link https://github.com/webpack/loader-utils#gethashdigest}
 */
export function getHashDigest(buffer: Buffer, hashType?: HashType, digestType?: DigestType, maxLength?: number): string;

````

### Additional Details
 * Last updated: Fri, 22 Aug 2025 12:02:36 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node), [webpack](https://npmjs.com/package/webpack)

# Credits
These definitions were written by [Gyusun Yeom](https://github.com/Perlmint), [Totooria Hyperion](https://github.com/TotooriaHyperion), [Piotr Błażejewicz](https://github.com/peterblazejewicz), and [Jesse Katsumata](https://github.com/Naturalclar).

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