gener-raw-to-ts
v0.0.1
Published
Convert raw object to typescript interfaces
Downloads
14
Maintainers
Readme
Raw to TS
Convert json object to typescript interfaces
Example
Code
const RawToTs = require('gener-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 gener-raw-to-ts