# @types/koa-json-error

> TypeScript definitions for koa-json-error

Latest version **3.1.7** (published 2025-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/koa-json-error
pnpm add @types/koa-json-error
yarn add @types/koa-json-error
bun add @types/koa-json-error
```

## Health

**Score 65/100 (B)** — status: stable.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.1.7 |
| Published | 2025-10-24 |
| First published | 2016-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

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

## Dependencies (1)

- [@types/koa](https://npm.io/package/@types/koa.md) *

## Recent versions

- 3.1.7 (latest) — 2025-10-24
- 3.1.6 (ts5.1) — 2023-11-07
- 3.1.4 (ts3.8) — 2021-11-03
- 3.1.3 (ts3.6) — 2021-07-09
- 3.1.2 (ts3.4) — 2017-11-09
- 3.1.1 (ts2.2) — 2017-03-30
- 3.0.2 (ts2.0) — 2016-12-19
- 3.1.5 — 2023-10-18
- 3.1.0 — 2017-02-23
- 3.0.3 — 2017-02-21
- 3.0.1 — 2016-09-19

## README

# Installation
> `npm install --save @types/koa-json-error`

# Summary
This package contains type definitions for koa-json-error (https://github.com/koajs/json-error).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-json-error.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-json-error/index.d.ts)
````ts
import Koa = require("koa");

type JSONError = Error & { status: number };

interface JSONErrorOptions {
    /**
     * Perform some task before calling `options.format`. Must be a function with the original err as its only argument.
     */
    preFormat?(err: JSONError): any;

    /**
     * Runs inmediatly after `options.preFormat`. It receives two arguments: the original `err` and the output of     `options.preFormat`. It should `return` a newly formatted error.
     */
    format?(err: JSONError, obj: any): any;

    /**
     * Runs inmediatly after `options.format`. It receives two arguments: the original `err` and the output of   `options.format`.   It should `return` a newly formatted error.
     */
    postFormat?(err: JSONError, obj: any): any;
}

/**
 * Error handler for pure Koa 2.0.0+ JSON apps
 */
declare function jsonError(options?: JSONErrorOptions): Koa.Middleware;

declare namespace jsonError {}
export = jsonError;

````

### Additional Details
 * Last updated: Fri, 24 Oct 2025 04:02:41 GMT
 * Dependencies: [@types/koa](https://npmjs.com/package/@types/koa)

# Credits
These definitions were written by [Mudkip](https://github.com/mudkipme).

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