# tscgen

> The core tscgen library for constructing and writing `interfaces`, `type aliases`, and `javascript objects`.

Latest version **0.0.16-8** (published 2021-03-14) · MIT license · 0 weekly downloads

## Install

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

## 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.0.16-8 |
| Published | 2021-03-14 |
| First published | 2021-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 153.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kevin Bai |
| Maintainers | kevinbai0 |

## Links

- npm: https://www.npmjs.com/package/tscgen
- npm.io page: https://npm.io/package/tscgen

## Recent versions

- 0.0.16-8 (latest) — 2021-03-14
- 0.0.16-7 — 2021-03-14
- 0.0.16-6 — 2021-03-14
- 0.0.16-5 — 2021-03-14
- 0.0.16-4 — 2021-03-14
- 0.0.16-3 — 2021-03-14
- 0.0.16-2 — 2021-03-14
- 0.0.16-1 — 2021-03-13
- 0.0.15 — 2021-03-04
- 0.0.14 — 2021-03-03
- 0.0.13 — 2021-03-03
- 0.0.12 — 2021-03-03
- 0.0.11 — 2021-03-03
- 0.0.10 — 2021-03-03
- 0.0.9 — 2021-03-03
- … 7 more at https://npm.io/package/tscgen/versions

## README

# tscgen

The core tscgen library for constructing and writing `interfaces`, `type aliases`, and `javascript objects`.

## Installation

Install with NPM:

```npm i -D tscgen```

Install With Yarn:

```yarn add --dev tscgen```

## Usage

### Creating an interface

```ts
import tscgen from 'tscgen';

const ISampleInterface = tscgen
  .interfaceBuilder('ISampleInterface')
  .markExport()
  .addBody({
    type: tscgen.stringType(),
    data: tscgen.numberType(1, 2, 3, 4)
    inputs: tscgen.booleanTuple(true, false)
  })

console.log(ISampleInterface.toString());

// output (after linted)

export interface ISampleInterface {
  type: string;
  data: 1 | 2 | 3 | 4;
  inputs: [true, false]
}
```

### Creating a Type Alias

```ts
import tscgen from 'tscgen';

const TestAlias = tscgen
  .typeDefBuilder('TestAlias')
  .addUnion(
    tscgen.arrayType(tscgen.stringType())
  )
  .addUnion(
    tscgen.stringType('none')
  )

console.log(TestAlias.toString());

// output (after linted)

type TestAlias = Array<string> | 'none';
```

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