# unpartial

> Unpartial a partialed object

Latest version **1.0.8** (published 2026-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install unpartial
pnpm add unpartial
yarn add unpartial
bun add unpartial
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2026-09-07 |
| First published | 2017-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 20 |
| Dependencies | 0 |
| Unpacked size | 33.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 5 |
| Author | Homa Wong (unional) |
| Maintainers | unional |

## Links

- npm: https://www.npmjs.com/package/unpartial
- Repository: https://github.com/cyberuni/unpartial
- Issues: https://github.com/cyberuni/unpartial/issues
- npm.io page: https://npm.io/package/unpartial

## Recent versions

- 1.0.8 (latest) — 2026-09-07
- 1.0.7 — 2026-09-01
- 1.0.6 — 2026-08-24
- 1.0.5 — 2023-06-03
- 1.0.4 — 2022-09-23
- 1.0.3 — 2022-09-13
- 1.0.2 — 2022-09-02
- 1.0.1 — 2022-09-01
- 1.0.0 — 2022-09-01
- 0.7.5 — 2022-06-11
- 0.7.4 — 2022-06-04
- 0.7.3 — 2022-05-31
- 0.7.0 — 2022-05-28
- 0.6.4 — 2021-12-05
- 0.6.3 — 2019-05-13
- … 14 more at https://npm.io/package/unpartial/versions

## README

# unpartial

[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]

[![GitHub NodeJS][github-nodejs]][github-action-url]
[![Codecov][codecov-image]][codecov-url]

[![Visual Studio Code][vscode-image]][vscode-url]
[![Wallaby.js][wallaby_image]][wallaby_url]

Unpartial a type.

It is very common to define a config type and `Partial<>` it in a function argument.
When we received the argument, we want to merge it with our default config before using it:

```ts
import { unpartial } from 'unpartial'

interface Config {
  require: { a: number }
  optional?: { a: number }
}
const defaultConfig: Config = { require: { a: 1 } }

function foo(givenConfig?: Partial<Config>) {
  const config = unpartial(defaultConfig, givenConfig);
  // use config with type safety
}
```

Code completion is available as you type:

```ts
const config = unpartial(defaultConfig, { /* code completion here */});
```

It also supports merging two default configs.
This is useful when you are extending the interface from another package/class.

```ts
import { unpartial } from 'unpartial'

import { Option, defaultOption } from 'another-package'

interface MyOption extends Option { ... }

const myDefaultOption = { ... }

function foo(givenOption?: Partial<MyOption>) {
  const option = unpartial(defaultOption, myDefaultOption, givenOption)
}
```

**This is deprecated** because currently TypeScript does not support optional generic type,
so it is not possible to create a satisfactory signature that works with both implicit and explicit type.

Instead, please use composition when combining 3 or more values:

```ts
unpartial(unpartial(defaultOption, myDefaultOption), givenOption)
```

There are 3 more functions available in this library:

- `unpartialRecursively()`: `unpartial()` deeply.\
  In practice, this does not seem to be useful. Maybe will be deprecated and removed in the future.
- `required()`: an alternative version of `unpartial()` with a different type management.\
  This will become identical to `unpartial()` in the future.
- `requiredDeep()`: an alternative version of `unpartialRecursively()` with a different type management.\
  This will become identical to `unpartial()` in the future.

`unpartial` is also exposed through [`type-plus`](https://github.com/unional/type-plus).
It contains many more functions and type utilities.

Feel free to check it out.

## Contribute

```sh
# after fork and clone
pnpm install

# begin making changes
git checkout -b <branch>
pnpm watch

# after making change(s)
git commit -m "<commit message>"
git push

# create PR
```

## Wallaby.js

[![Wallaby.js][wallaby_image_lg]][wallaby_url]

This repository contributors are welcome to use
[Wallaby.js OSS License][wallaby_url] to get
test results immediately as you type, and see the results in
your editor right next to your code.

[codecov-image]: https://codecov.io/gh/cyberuni/unpartial/branch/main/graph/badge.svg
[codecov-url]: https://codecov.io/gh/cyberuni/unpartial
[downloads-image]: https://img.shields.io/npm/dm/unpartial.svg?style=flat
[downloads-url]: https://npmjs.org/package/unpartial
[github-nodejs]: https://github.com/cyberuni/unpartial/workflows/release/badge.svg
[github-action-url]: https://github.com/cyberuni/unpartial/actions
[npm-image]: https://img.shields.io/npm/v/unpartial.svg?style=flat
[npm-url]: https://npmjs.org/package/unpartial
[vscode-image]: https://img.shields.io/badge/vscode-ready-green.svg
[vscode-url]: https://code.visualstudio.com/
[wallaby_image]: https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=flat&logo=github
[wallaby_image_lg]: https://img.shields.io/badge/wallaby.js-powered-blue.svg?style=for-the-badge&logo=github
[wallaby_url]: https://wallabyjs.com/oss/

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