Skip to content

Instantly share code, notes, and snippets.

@jurijsk
Created June 8, 2023 21:16
Show Gist options
  • Save jurijsk/381229c4e58c54a8447ed48351a5fc76 to your computer and use it in GitHub Desktop.
Save jurijsk/381229c4e58c54a8447ed48351a5fc76 to your computer and use it in GitHub Desktop.
Dirty way to generate props definitions from the object
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