markdown-to-ts

0.1.4 • Public • Published

Markdown to typescript, tsx converter

npm Downloads license

Create type,tsx based on the markdown table.

Supported Node.js

Supports versions 10 and above

Install

npm i -g markdown-to-ts

Usage

  1. 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      |
  1. 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;
  1. 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;

Package Sidebar

Install

npm i markdown-to-ts

Weekly Downloads

2

Version

0.1.4

License

MIT

Unpacked Size

11 kB

Total Files

8

Last publish

Collaborators

  • devbono