Created
June 8, 2023 21:16
-
-
Save jurijsk/381229c4e58c54a8447ed48351a5fc76 to your computer and use it in GitHub Desktop.
Dirty way to generate props definitions from the object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let typestr = ""; | |
for (const key in properties) { | |
if (Object.prototype.hasOwnProperty.call(properties, key)) { | |
const value = properties[key]; | |
typestr += key + ": "; | |
let t = <string> typeof value; | |
t = t === "undefined" ? "unknown" : t; | |
if(t === "object" && Array.isArray(value)) { | |
let tt = <string> typeof value[0]; | |
tt = tt === "undefined" ? "unknown" : tt; | |
tt = tt === "object" ? "unknown" : tt; | |
typestr += tt + "[];"; | |
} else { | |
typestr += t + ";"; | |
} | |
typestr + '\r\n'; | |
} | |
} | |
console.log(typestr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment