fix
This commit is contained in:
parent
b6b849d902
commit
6b5f21a420
|
|
@ -389,8 +389,15 @@ const propTypings = (prop: FNCompDef | undefined, types: any, meta: any) => {
|
||||||
"active",
|
"active",
|
||||||
"_meta",
|
"_meta",
|
||||||
`\
|
`\
|
||||||
|
${
|
||||||
|
prop.typings
|
||||||
|
? `
|
||||||
${prop.typings};
|
${prop.typings};
|
||||||
return typings;`
|
return typings;
|
||||||
|
`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
|
`
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const typings = typings_fn(active, meta);
|
const typings = typings_fn(active, meta);
|
||||||
|
|
@ -406,7 +413,7 @@ return typings;`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(typings_fn.toString());
|
console.log('WARNING: typings prasi error, bilang mas rizky plis...');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,16 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => {
|
||||||
const comp_types = {} as Record<string, string>;
|
const comp_types = {} as Record<string, string>;
|
||||||
|
|
||||||
for (const m of cur_path) {
|
for (const m of cur_path) {
|
||||||
|
if (m.item.component?.props) {
|
||||||
|
for (const [name, prop] of Object.entries(m.item.component.props)) {
|
||||||
|
if (prop.meta?.type === "content-element") {
|
||||||
|
vars[name] = { mode: "prop", val: "ReactElement" };
|
||||||
|
} else {
|
||||||
|
vars[name] = { mode: "prop", val: prop.value };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m.mitem?.parent && (m.mitem?.parent as any).get("meta")) {
|
if (m.mitem?.parent && (m.mitem?.parent as any).get("meta")) {
|
||||||
let prop_name = "";
|
let prop_name = "";
|
||||||
const parent = m.mitem?.parent.parent as unknown as TypedArray<any>;
|
const parent = m.mitem?.parent.parent as unknown as TypedArray<any>;
|
||||||
|
|
@ -49,7 +59,9 @@ export const declareScope = (p: PG, meta: IMeta, monaco: Monaco) => {
|
||||||
if (prop_name && m_prev && m_prev.item.component) {
|
if (prop_name && m_prev && m_prev.item.component) {
|
||||||
const prop_typings = m_prev.item.component.props[prop_name].typings;
|
const prop_typings = m_prev.item.component.props[prop_name].typings;
|
||||||
try {
|
try {
|
||||||
const typings_src = prop_typings.substring(`const typings = `.length);
|
const typings_src = prop_typings?.substring(
|
||||||
|
`const typings = `.length
|
||||||
|
);
|
||||||
const typings_fn = new Function(`return ${typings_src}`);
|
const typings_fn = new Function(`return ${typings_src}`);
|
||||||
const typings = typings_fn();
|
const typings = typings_fn();
|
||||||
if (typeof typings === "object") {
|
if (typeof typings === "object") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue