Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richie-south/typescript-type-generator
Generate interfaces on the go! Network request? Then generate interfaces for response!
https://github.com/richie-south/typescript-type-generator
interface interface-builder npm types typescript
Last synced: about 5 hours ago
JSON representation
Generate interfaces on the go! Network request? Then generate interfaces for response!
- Host: GitHub
- URL: https://github.com/richie-south/typescript-type-generator
- Owner: richie-south
- License: mit
- Created: 2018-10-31T16:29:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-03T08:30:32.000Z (almost 6 years ago)
- Last Synced: 2024-11-01T21:18:45.096Z (15 days ago)
- Topics: interface, interface-builder, npm, types, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/typescript-interface-generator
- Size: 402 KB
- Stars: 18
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typescript-type(interface)-generator
Generate interfaces form javascript objects
## install
```
npm install typescript-interface-generator
```## example
```javascript
import { createInterfacesFromObject } from 'typescript-interface-generator'
const code = createInterfacesFromObject(
'User',
{
id: 1,
data: {
name: 'Richard',
articles: [
{
id: 0,
title: 'article 0',
},
{
id: 0,
title: 'article 0',
},
{
anotherObject: 10,
},
],
},
}
)console.log(code)
/**
** CODE OUTPUT **interface User {
id: number;
data: Data;
}interface Data {
name: string;
articles: Array;
}interface Articles {
id: number;
title: string;
}interface Articles1 {
anotherObject: number;
}
*/```
## API
### createInterfacesFromObject
Takes a name and a javascript object and returns a string with typescript interfaces
**Syntax**
```javascript
import { createInterfacesFromObject } from 'typescript-interface-generator'createInterfacesFromObject('NAME', {})
```***Parameters***
* string
* name of (parent) interface
* object
* object that should be turned to interfaces***Return value***
string: contains typescript interfaces
## gif example