# nullables

> A way to specify nullable types in TypeScript whilst still getting the correct data at runtime.

Latest version **1.0.2** (published 2021-01-12) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-01-12 |
| First published | 2021-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alistair Smith |
| Maintainers | aabbccsmith |

## Links

- npm: https://www.npmjs.com/package/nullables
- Repository: https://github.com/mongo-ts/nullables
- Homepage: https://github.com/mongo-ts/nullables#readme
- Issues: https://github.com/mongo-ts/nullables/issues
- npm.io page: https://npm.io/package/nullables

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.1.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 1.0.2 (latest) — 2021-01-12
- 1.0.1 — 2021-01-12
- 1.0.0 — 2021-01-12

## README

## `nullables`

A way to specify nullable types in TypeScript whilst still getting the correct data at runtime.

#### Usage

```ts
import { Property, NullableString, RemapProperties } from 'nullables';

class Person {
  @Property
  email!: string;

  @Property
  age!: number;

  @Property
  first_name!: NullableString;
}

// Remap properties to now have correct types at compile/dev time
// but maintain String at runtime (with the knowledge of it being nullable)
const person = new Person() as RemapProperties<Person>;

person.age; // => number
person.first_name; // => string | null
person.email; // => string
```

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