0.0.16-8 • Published 4 years ago

tscgen v0.0.16-8

Weekly downloads
434
License
MIT
Repository
-
Last release
4 years ago

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

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

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';
0.0.16-1

4 years ago

0.0.16-3

4 years ago

0.0.16-2

4 years ago

0.0.16-5

4 years ago

0.0.16-4

4 years ago

0.0.16-7

4 years ago

0.0.16-6

4 years ago

0.0.16-8

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago