Skip to content

guqingming/raw-to-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raw to TS

Convert json object to typescript interfaces

Example

Code

const RawToTs = require('raw-to-ts')

const json = {
  cats: [
    {name: 'Kittin'},
    {name: 'Mittin'}
  ],
  favoriteNumber: 42,
  favoriteWord: 'Hello'
}

RawToTs(json).forEach( typeInterface => {
  console.log(typeInterface)
})

Output:

interface Request {
  cats: Cat[];
  favoriteNumber: number;
  favoriteWord: string;
}
interface Cat {
  name: string;
}

Converter

  • Array type merging (Big deal)
  • Union types
  • Duplicate type prevention
  • Optional types
  • Array types

Setup

$ npm install --save raw-to-ts

About

yapi raw to interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published