0.1.4 • Published 2 years ago

raw-to-ts v0.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years 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.1.4

2 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

1.0.0

3 years ago