ts-json-as-const

1.0.7 • Public • Published

ts-json-as-const

License: ISC

A (very) simple CLI tool that reads JSON files and creates .d.ts files with their keys/values explicitly defined

Install

npm install ts-json-as-const

Usage

npx ts-json-as-const [path/to/json/file.json ...]

Example

Input example.json

{
  "foo": {
    "bar": false,
    "baz": true,
    "i-can": "hascheezburger"
  },
  "array": [ 1, 2, 3, { "foo": 1, "bar": [ 4, 5 ] }, 6 ]
}

Output example.json.d.ts

interface Example {
  foo: {
    bar: false;
    baz: true;
    'i-can': 'hascheezburger';
  },
  array: [
    1,
    2,
    3,
    {
      foo: 1;
      bar: [
        4,
        5
      ]
    },
    6
  ]
}

declare const Example: Example;

export = Example;

Author

👤 Bethany Hitch

Package Sidebar

Install

npm i ts-json-as-const

Weekly Downloads

347

Version

1.0.7

License

ISC

Unpacked Size

4.01 kB

Total Files

3

Last publish

Collaborators

  • dfoverdx