fix: make isJSExpression more robust

This commit is contained in:
LeoYuan 袁力皓 2022-11-24 19:24:59 +08:00 committed by 刘菊萍(絮黎)
parent 43b2175792
commit 01ce70c06c

View File

@ -128,8 +128,18 @@ export interface CompositeObject {
[key: string]: CompositeValue;
}
/**
* 为了避免把 { type: 'JSExpression', extType: 'function' } 误判为表达式,故增加如下逻辑。
*
* 引擎中关于函数的表达:
* 开源版本:{ type: 'JSFunction', source: '', value: '' }
* 内部版本:{ type: 'JSExpression', source: '', value: '', extType: 'function' }
* 能力是对标的,不过开源的 react-renderer 只认识第一种,而内部只识别第二种(包括 Java 代码、RE)。
* @param data
* @returns
*/
export function isJSExpression(data: any): data is JSExpression {
return data && data.type === 'JSExpression';
return data && data.type === 'JSExpression' && data.extType !== 'function';
}
export function isJSFunction(x: any): x is JSFunction {