js: fix type error

This commit is contained in:
pengfei.zhou 2022-12-29 09:02:55 +08:00 committed by osborn
parent be4fb05f91
commit 37d2df9eea
2 changed files with 9 additions and 4 deletions

View File

@ -17203,8 +17203,10 @@ var doric = (function (exports) {
} }
hookBeforeNativeCall(context); hookBeforeNativeCall(context);
Reflect.apply(callback.resolve, context, argumentsList); Reflect.apply(callback.resolve, context, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId); context.callbacks.delete(callbackId);
} }
}
function jsCallReject(contextId, callbackId, args) { function jsCallReject(contextId, callbackId, args) {
var arguments$1 = arguments; var arguments$1 = arguments;
@ -17224,8 +17226,10 @@ var doric = (function (exports) {
} }
hookBeforeNativeCall(context); hookBeforeNativeCall(context);
Reflect.apply(callback.reject, context.entity, argumentsList); Reflect.apply(callback.reject, context.entity, argumentsList);
if (callback.retained !== true) {
context.callbacks.delete(callbackId); context.callbacks.delete(callbackId);
} }
}
var Context = /** @class */ (function () { var Context = /** @class */ (function () {
function Context(id) { function Context(id) {
this.callbacks = new Map; this.callbacks = new Map;
@ -17260,7 +17264,8 @@ var doric = (function (exports) {
var functionId = uniqueId('function'); var functionId = uniqueId('function');
this.callbacks.set(functionId, { this.callbacks.set(functionId, {
resolve: func, resolve: func,
reject: function () { loge("This should not be called"); } reject: function () { loge("This should not be called"); },
retained: true,
}); });
return functionId; return functionId;
}; };

View File

@ -23,7 +23,7 @@ export function obj2Model(obj: Model, convertor: (v: Function) => string): Model
return obj.map(e => obj2Model(e, convertor)) as Model return obj.map(e => obj2Model(e, convertor)) as Model
} else if (obj instanceof Object) { } else if (obj instanceof Object) {
if (Reflect.has(obj, 'toModel') && Reflect.get(obj, 'toModel') instanceof Function) { if (Reflect.has(obj, 'toModel') && Reflect.get(obj, 'toModel') instanceof Function) {
obj = Reflect.apply(Reflect.get(obj, 'toModel'), obj, []) obj = Reflect.apply(Reflect.get(obj, 'toModel') as Function, obj, [])
return obj return obj
} else { } else {
for (let key in obj) { for (let key in obj) {