ts-declaration-gen

1.0.1 • Public • Published

➕ts-declaration-gen

中文

📺背景

写ts的时候,总是知道了一个数据结构,但要一行行地写类型,很麻烦,因此做了一个小工具解决此问题

🔧使用

declarationGen({ a: 1 })
/*
{
  a: number;
}
*/

declarationGen({
  "a": 1,
  "b": "1",
  "c": {
    "d": 1,
    "e": [
      "1",
      {
        "g": 1,
        "r": "asd",
        "gg": true
      },
      1
    ]
  }
})
/*
{
  a: number;
  b: string;
  c: {
    d: number;
    e: number | {
      g: number;
      r: string;
      gg: boolean;
    } | string [];
  };
}
*/
english

📺background

when writing typescript,we have allready known a json.however,we must write the declaration line and line,that's so difficult.so,there is a little tool to fix it.

🔧usage

declarationGen({ a: 1 })
/*
{
  a: number;
}
*/

declarationGen({
  "a": 1,
  "b": "1",
  "c": {
    "d": 1,
    "e": [
      "1",
      {
        "g": 1,
        "r": "asd",
        "gg": true
      },
      1
    ]
  }
})
/*
{
  a: number;
  b: string;
  c: {
    d: number;
    e: number | {
      g: number;
      r: string;
      gg: boolean;
    } | string [];
  };
}
*/

Package Sidebar

Install

npm i ts-declaration-gen

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

8.73 kB

Total Files

4

Last publish

Collaborators

  • lhyt