@wrule/prober
v0.1.8
Published
Get TypeScript type from JavaScript value and generate TypeScript code
Downloads
27
Readme
Install
$ npm install @wrule/prober
Usage
Code
const path = require('path');
const { Prober } = require('@wrule/prober');
const obj = {
a: [{name: 'kim'}, {name: 'jim'}]
};
const dstPath = path.join(__dirname, 'output');
const prober = new Prober();
const type = prober.Update(obj, 'test', dstPath);
console.log(type.TypeDesc);
Output
Console
ITest_08890C26
Generated code
import { IA_ArrayItem_31B51A0F } from './a_ArrayItem_31B51A0F';
export interface ITest_08890C26 {
'a': IA_ArrayItem_31B51A0F[];
}
export interface IA_ArrayItem_31B51A0F {
'name': string;
}