Skip to content
/ prober Public

Get TypeScript type from JavaScript value and generate TypeScript code

License

Notifications You must be signed in to change notification settings

wrule/prober

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hasha

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;
}

About

Get TypeScript type from JavaScript value and generate TypeScript code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published