0.0.16-8 • Published 3 years ago

tscgen v0.0.16-8

Weekly downloads
434
License
MIT
Repository
-
Last release
3 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

3 years ago

0.0.16-3

3 years ago

0.0.16-2

3 years ago

0.0.16-5

3 years ago

0.0.16-4

3 years ago

0.0.16-7

3 years ago

0.0.16-6

3 years ago

0.0.16-8

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago