# raw-to-ts **Repository Path**: mycssweb/raw-to-ts ## Basic Information - **Project Name**: raw-to-ts - **Description**: yapi中的raw转interface - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-16 - **Last Updated**: 2022-04-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Raw to TS ### Convert json object to typescript interfaces # Example ### Code ```javascript 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: ```typescript 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 ```sh $ npm install --save raw-to-ts ```