0.0.3 • Published 8 months ago

gener-raw-to-ts v0.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

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
0.0.3

8 months ago

0.0.1

9 months ago

0.1.5

9 months ago

0.1.4

9 months ago