ts-void
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published


TS-VOIDɸ

“The eternal void is filled with infinite possibilities” ~ Laozi

Typescript Void npm

Void 🔮

How do you check if this variable contains a value?

let value: Value;

You may initialize it with undefined or null, but what if Value is a generic you don't control, and it can be one of these values?

import { Void } from "ts-void";

You may use Void as a new primitive value.

let value: Value | Void;

then you can check if the variable is Void.

if (value !== Void) {
  // Now the value is only of type "Value".
}

You may also use the utility type.

import { type NonVoid } from "ts-void";

And extract the original type from the union.

type Extracted = NonVoid<T | Void>; // equals to T.

Dependents (0)

Package Sidebar

Install

npm i ts-void

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

4.12 kB

Total Files

6

Last publish

Collaborators

  • paol-imi-org