js2types
v0.0.2
Published
Generate TypeScript's types from any JavaScript object.
Downloads
3
Maintainers
Readme
Generate TypeScript's types from any JavaScript object.
How to use package
Import package from js2types
import Js2Types from "js2types"
const userData = {
name:"Anthony",
admin:true,
}
const typeName = "UserData"
const genUserType = new Js2Types(userData,typeName)
const userType = genUserType.type
// Output
//UserData:start
export type UserData = {
name:string
admin:boolean
}
//UserData:end
// Save type
js2Types.save(`${process.cwd()}/test/types.ts`)
// Output
//UserData:start
export type UserData = {
name:string
admin:boolean
}
//UserData:end