1.1.10 • Published 5 years ago

typeof-jsonc v1.1.10

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

typeof-jsonc

Convert jsonc to type of typescript

use

install

npm install typeof-jsonc -S

or

yarn add typeof-jsonc -S

demo

import * as fs from 'fs';
import * as path from 'path';

import { typeofJsonc } from '../src/index';

const text = fs.readFileSync(path.resolve('./demo/test.jsonc'), {
  encoding: 'utf-8',
});

console.log(
  typeofJsonc(text, 'IResponse', { rootFlags: 1, disallowComments: false }),
);

test.jsonc

{
  "name": "lanfeng", // this is name
  // this is demo
  "demo": {
    "hello": "world"
  },
  /** this is arr */
  "arr": [
    {
      "age": 1
    },
    2
  ]
}

the result

interface Demo {
    hello: string;
}


/**
 * this is arr
 */
interface Arr {
    age: number;
}


interface IResponse {
    /**
     * this is name
     */
    name: string;
    /**
     * this is demo
     */
    demo: Demo;
    /**
     * this is arr
     */
    arr: (Arr | number)[];
}
1.1.11-beta.2

5 years ago

1.1.11-beta.1

5 years ago

1.1.11-beta.0

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.9-0

5 years ago

1.1.8

5 years ago

1.1.8-0

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.5-0

5 years ago

1.1.4

5 years ago

1.1.4-0

5 years ago

1.1.3

5 years ago

1.1.2-1

5 years ago

1.1.2-0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3-2

5 years ago

1.0.3-1

5 years ago

1.0.3-0

5 years ago

1.0.2

5 years ago

1.0.2-0

5 years ago

1.0.1

5 years ago

1.0.1-0

5 years ago

1.0.0

5 years ago