1.2.5 • Published 1 year ago

@peteradeojo/typegencli v1.2.5

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

TypeGen

TypegenCLI is a cli tool that helps developers generate typescript types from JSON data. This is especially useful for generating types for API responses in development

Usage

CLI

Install the Typegen Server globally to use the cli

$ npm i -g @peteradeojo/typegencli

Then run

$ typegen -h

Start the listener in a terminal window

$ typegen -l/--listen [PORT]

Generator

Install the @peteradeojo/typegencli inn your project

$ npm i @peteradeojo/typegencli

Create a generator

const {sendData} = require('@peteradeojo/typegencli');

const generator = sendData(3000); // 3000 is the port the listener is running on. This should match the port given for the -l/--listen options

Pass a type name and the JSON object you want to generate types for into the generator function

// ...
generator("Cat", data); // data can object from API response or parsed JSON. Any object at all will do

// ...

This will generate a type and output it to the listener terminal window

type Cat = {
  id: number;
  color: string;
  picture: string;
}

It would also output to a typegen/Cat.ts file in your project directory

Demo Video

Watch the demo

https://twitter.com/i/status/1759724420602491141

1.2.5

1 year ago

1.2.4

1 year ago

0.6.6

1 year ago

0.6.5

1 year ago

0.5.0

1 year ago

0.6.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

1.0.0

1 year ago