Socket
Socket
Sign inDemoInstall

@peteradeojo/typegencli

Package Overview
Dependencies
87
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @peteradeojo/typegencli

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


Version published
Weekly downloads
95
increased by630.77%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 27 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc