# @gilbarbara/types

> Reusable typescript typings

Latest version **0.2.2** (published 2023-08-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gilbarbara/types
pnpm add @gilbarbara/types
yarn add @gilbarbara/types
bun add @gilbarbara/types
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2023-08-02 |
| First published | 2022-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Gil Barbara |
| Maintainers | gilbarbara |
| Keywords | typescript, typings |

## Links

- npm: https://www.npmjs.com/package/@gilbarbara/types
- Repository: https://github.com/gilbarbara/types
- Issues: https://github.com/gilbarbara/types/issues
- npm.io page: https://npm.io/package/@gilbarbara/types

## Dependencies (1)

- [type-fest](https://npm.io/package/type-fest.md) ^4.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2023-08-02
- 0.2.1 — 2023-08-02
- 0.2.0 — 2023-08-01
- 0.1.1 — 2022-04-22
- 0.1.0 — 2022-04-22

## README

# @gilbarbara/types

[![npm version](https://badge.fury.io/js/%40gilbarbara%2Ftypes.svg)](https://badge.fury.io/js/%40gilbarbara%2Ftypes) [![CI](https://github.com/gilbarbara/types/actions/workflows/main.yml/badge.svg)](https://github.com/gilbarbara/types/actions/workflows/main.yml)

Reusable typescript typings.

## Setup

```sh
npm i @gilbarbara/types
```

For convenience, the `type-fest` package is re-exported.

## Types

### Aliases

```typescript
type NumberOrNull = number | null;
type StringOrNull = string | null;
type StringOrNumber = string | number;

type PlainObject<T = unknown> = Record<string, T>;

type GenericFunction<T = unknown> = (...arguments_: any[]) => T;
type VoidFunction = () => void;
```


### Common

```typescript
type AsyncStatus = 'IDLE' | 'PENDING' | 'SUCCESS' | 'ERROR';

interface AsyncFlow {
  message: string;
  status: AsyncStatus;
}

interface AsyncFlowWithCache extends AsyncFlow {
  updatedAt: number;
}

interface AsyncFlowWithData<T = any> extends AsyncFlow {
  data: T;
}

interface AsyncFlowWithDataAndCache<T = any> extends AsyncFlowWithData<T> {
  updatedAt: number;
}

type HttpMethods =
  | 'CONNECT'
  | 'DELETE'
  | 'GET'
  | 'HEAD'
  | 'OPTIONS'
  | 'PATCH'
  | 'POST'
  | 'PUT';

interface IdName {
  id: string;
  name: string;
}

interface LabelValue {
  label: string;
  value: string;
}
```

### Utilities

```typescript
/**
 * Narrow down a Record to a plain object.
 */
type NarrowPlainObject<T extends Record<string, any>> = Exclude<
  T,
  Array<unknown> | Function | Map<unknown, unknown> | Set<unknown>
>;
```

```typescript
/**
 * An object without excluded types.
 */
type RemoveType<TObject, TExclude = undefined> = {
  [Key in keyof TObject as TObject[Key] extends TExclude ? never : Key]: TObject[Key];
};
```

```typescript
/**
 * A strict plain object with a specific set of keys.
 */
type StrictObject<TObject extends Record<PropertyKey, unknown>, TExpected> = TExpected & {
  [Key in keyof TObject]: Key extends keyof TExpected ? TExpected[Key] : never;
};
```

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