HarmonyOS NEXT @Concurrent装饰器报错?

HarmonyOS NEXT @Concurrent装饰器报错?

Concurrent装饰器始终报错:Decorator function return type is ‘void | TypedPropertyDescriptor<unknown>’ but is expected to be ‘void’ or ‘any’. Type ‘TypedPropertyDescriptor<unknown>’ is not assignable to type ‘void’. <ArkTSCheck>

本文参与了 【 HarmonyOS NEXT 技术问答冲榜,等你来战!】欢迎正在阅读的你也加入。

阅读 646
1 个回答

具体参考代码:

import taskpool from '@ohos.taskpool'; 
 
@Concurrent 
function testPromise(args1: number, args2: number): Promise<number> { 
  return new Promise<number>((testFuncA, testFuncB) => { 
    testFuncA(args1 + args2); 
  }); 
} 
 
export class FCDemoTest { 
  public static instance: FCDemoTest = new FCDemoTest(); 
 
  private constructor() { 
  } 
 
  checkInfo() { 
    let task1: taskpool.Task = new taskpool.Task(testPromise, 1, 2); 
    taskpool.execute(task1).then((d: object) => { 
    }).catch((e: object) => { 
    }) 
  } 
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进