diff --git a/interfaces/kits/ani/common_event/ets/@ohos.commonEventManager.ets b/interfaces/kits/ani/common_event/ets/@ohos.commonEventManager.ets index 5ea46d91b62a13fea7e780615192cd61256e960c..9c0cee0e6d0ec08dfa19369fd6910917428600ab 100644 --- a/interfaces/kits/ani/common_event/ets/@ohos.commonEventManager.ets +++ b/interfaces/kits/ani/common_event/ets/@ohos.commonEventManager.ets @@ -25,7 +25,7 @@ const ERROR_PARAM_INVALID = 401; const errorParamInvalid: BusinessError = {code: ERROR_PARAM_INVALID, data: "Invalid parameter"}; type ResolveCallback = (data: T) => void; -type RejectCallback = (err: Object) => void; +type RejectCallback = (err: Error) => void; namespace commonEventManager { loadLibrary("ani_commoneventmanager.z"); @@ -81,7 +81,7 @@ namespace commonEventManager { } export function publishAsUser(event: string, userId: number, callback: AsyncCallback): void { - let publishAsUserId: Int = userId as Int; + let publishAsUserId: Int = userId.toInt(); let task = taskpool.execute(commonEventManager.publishAsUserExecute, event, publishAsUserId); task.then((e: NullishType)=>{ let resultCode: Int = e as Int; @@ -100,7 +100,7 @@ namespace commonEventManager { export function publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback): void { - let publishAsUserId: Int = userId as Int; + let publishAsUserId: Int = userId.toInt(); let task = taskpool.execute(commonEventManager.publishAsUserWithOptionsExecute, event, publishAsUserId, options); task.then((e: NullishType)=>{ let resultCode: Int = e as Int; @@ -213,7 +213,7 @@ namespace commonEventManager { let task = taskpool.execute(commonEventManager.removeStickyCommonEventExecute, event); task.then((data: NullishType): void => { resolve(undefined); - }, (error: Object): void => { + }, (error: Error): void => { hilog.error(0xD001202, TAG, 'removeStickyCommonEvent Promise error'); reject(error); }); @@ -236,7 +236,7 @@ namespace commonEventManager { let task = taskpool.execute(commonEventManager.setStaticSubscriberStateExecute, enable); task.then((e: NullishType): void => { resolve(undefined); - }, (error: Object): void => { + }, (error: Error): void => { hilog.error(0xD001202, TAG, 'setStaticSubscriberState Promise error'); reject(error); }); @@ -249,7 +249,7 @@ namespace commonEventManager { let task = taskpool.execute(commonEventManager.setStaticSubscriberStateWithEventsExecute, enable, events); task.then((e: NullishType): void => { resolve(undefined); - }, (error: Object): void => { + }, (error: Error): void => { hilog.error(0xD001202, TAG, 'setStaticSubscriberStateExecute Promise error.'); reject(error); });