Markdown to typescript, tsx converter
Create type,tsx based on the markdown table.
Supported Node.js
Supports versions 10 and above
Install
npm i -g markdown-to-ts
Usage
- If there is no xxx.type.md file in the current path, Sample.type.md is created.
md-cli type
- Sample.type.md
| key | type | description |
|----------|----------------------------------|---------------|
| basic? | string | Optional type |
| union | number,string | UnionType |
| union2 | "name","age" | UnionType |
| tuple | [number,string] | TupleType |
| tuple2 | ["string",1,{}] | TupleType |
| argsFunc | (args:number,args2:string)=>void | function |
- Reads the xxx.type.md file in the current path and creates the xxx.ts file.
md-cli type
- SampleType.ts
type SampleType = {
basic?: string; //Optional type
union: number | string; //UnionType
union2: 'name' | 'age'; //UnionType
tuple: [number, string]; //TupleType
tuple2: ['string', 1, {}]; //TupleType
argsFunc: (args: number, args2: string) => void; //function
};
export default SampleType;
- Reads the xxx.type.md file in the current path and creates the xxx.tsx file.
md-cli component
- Sample.tsx
type Props = {
basic?: string; //Optional type
union: number | string; //UnionType
union2: 'name' | 'age'; //UnionType
tuple: [number, string]; //TupleType
tuple2: ['string', 1, {}]; //TupleType
argsFunc: (args: number, args2: string) => void; //function
[key: string]: any;
};
function Sample(props: Props) {
return <div>Sample Component</div>;
}
export default Sample;