@cc-heart/object-to-declare
v1.2.5
Published
object2declare
Downloads
8
Readme
object-to-declare
Object-to-Declare is a lightweight utility library that allows developers to easily generate TypeScript type declarations from JavaScript objects or arrays of objects. This can save significant time and effort when writing TypeScript code, especially for large projects or APIs.
install
You can installObject-to-Declare
via npm:
npm install @cc-heart/object-to-declare
Usage
Basic Usage
To use Object-to-Declare, simply import the library and call the generateTypeDeclaration
function with the object or array of objects you wish to generate a type declaration for:
import generateTypeDeclaration from '@cc-heart/object-to-declare'
const myObject = {
id: 1,
name: 'John Smith',
age: 30,
email: '[email protected]'
}
const typeDeclaration = generateTypeDeclaration(myObject)
console.log(typeDeclaration)
// Output: interface IRootName {
// id: number
// name: string
// age: number
// email: string
// }