1.1.10 • Published 6 years ago
typeof-jsonc v1.1.10
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
6 years ago
1.1.11-beta.1
6 years ago
1.1.11-beta.0
6 years ago
1.1.10
6 years ago
1.1.9
6 years ago
1.1.9-0
6 years ago
1.1.8
6 years ago
1.1.8-0
6 years ago
1.1.7
6 years ago
1.1.6
6 years ago
1.1.5
6 years ago
1.1.5-0
6 years ago
1.1.4
6 years ago
1.1.4-0
6 years ago
1.1.3
6 years ago
1.1.2-1
6 years ago
1.1.2-0
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.3-2
6 years ago
1.0.3-1
6 years ago
1.0.3-0
6 years ago
1.0.2
6 years ago
1.0.2-0
6 years ago
1.0.1
6 years ago
1.0.1-0
6 years ago
1.0.0
6 years ago