larksuite / node-sdk

larksuite open sdk for nodejs
MIT License
153 stars 31 forks source link

事件注册没有审批的几个公用事件 #98

Closed LinLin00000000 closed 3 months ago

LinLin00000000 commented 3 months ago

文档:https://open.feishu.cn/document/server-docs/approval-v4/event/common-event/approval-task-event

wsClient.start({
  eventDispatcher: new Lark.EventDispatcher({}).register({
    approval_task: async data => {
      console.log('approval_task', data)
    },
  }),
})

会有警告

Object literal may only specify known properties, and 'approval_task' does not exist in type 'IHandles'.ts(2353)

但是直接运行使用却没有问题

mazhe-nerd commented 3 months ago

Duplicate of:https://github.com/larksuite/node-sdk/issues/64

mazhe-nerd commented 3 months ago

可以使用范型来定义缺失的类型:

new WSClient({...baseConfig}).start({
  eventDispatcher: new Lark.EventDispatcher({}).register<{test?: 'xxxxx'}>({
    'test': 'xxxxx',
    'im.message.receive_v1': async (data) => {}
  })
});