This commit is contained in:
Rizky 2024-02-02 04:34:59 +07:00
parent a71800d7e5
commit 9532590735
1 changed files with 7 additions and 1 deletions

View File

@ -47,7 +47,13 @@ export const extractProp = (prop: {
for (const [k, v] of Object.entries(props)) {
if (v.type) {
propTypes.push(`const ${k}: ${trim(v.type, "; \n")};`);
let const_or_type = "const";
let str = v.type;
if (v.type.startsWith("type:")) {
str = v.type.substring("type:".length);
const_or_type = "type";
}
propTypes.push(`${const_or_type} ${k}: ${trim(str, "; \n")};`);
} else if (v.val) {
if (typeof v.val === "object" && isValidElement(v.val)) {
propTypes.push(`const ${k}: ReactElement;`);