Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junqiuzhang/babel-plugin-interface-to-schema
babel plugin transform interface to schema
https://github.com/junqiuzhang/babel-plugin-interface-to-schema
babel-plugin interface schema transform
Last synced: 7 days ago
JSON representation
babel plugin transform interface to schema
- Host: GitHub
- URL: https://github.com/junqiuzhang/babel-plugin-interface-to-schema
- Owner: junqiuzhang
- Created: 2019-11-30T13:56:11.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T02:02:19.000Z (about 2 years ago)
- Last Synced: 2024-04-24T21:21:07.516Z (9 months ago)
- Topics: babel-plugin, interface, schema, transform
- Language: JavaScript
- Size: 106 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Babel Plugin Interface To Schema
a babel plugin that transform ts interface to schema
## Example
**before:**```
interface IGrandFather {
gra: number; // GrandFather
}
interface IFather extends IGrandFather {
fat: number; // Father
}
interface IProps extends IFather {
boo: boolean; // boolean
num: number; // number
str: string; // string
obj: Object; // object
obj2: {
child: IChild;
};
arr: Array; // Array
arr2: Array;
arr3: Array<{
child: IChild;
}>;
fun: Function; // Function
fun2: (n: number) => void; // Function
child: IChild;
}
interface IChild {
name: string;
}
```
**after:**```
{
"type": "object",
"title": "IProps",
"properties": [
{ "title": "gra", "type": "number" },
{ "title": "fat", "type": "number" },
{ "title": "boo", "type": "boolean" },
{ "title": "num", "type": "number" },
{ "title": "str", "type": "string" },
{ "title": "obj", "type": "object" },
{
"type": "object",
"properties": [
{
"title": "child",
"type": "object",
"properties": [{ "title": "name", "type": "string" }]
}
]
},
{ "title": "arr", "type": "array", "items": { "type": "boolean" } },
{
"title": "arr2",
"type": "array",
"items": {
"type": "object",
"properties": [{ "title": "name", "type": "string" }]
}
},
{
"title": "arr3",
"type": "array",
"items": {
"type": "object",
"properties": [
{
"title": "child",
"type": "object",
"properties": [{ "title": "name", "type": "string" }]
}
]
}
},
{ "title": "fun", "type": "function" },
{ "title": "fun2", "type": "function" },
{
"title": "child",
"type": "object",
"properties": [{ "title": "name", "type": "string" }]
}
]
}```
## Usage
**.babelrc**```
{
"plugins": [
"@babel/plugin-syntax-typescript",
"./src/index.js"
]
}
```