Answered

Type 'undefined' is not assignable to type 'Promise'.

  • 21 May 2021
  • 1 reply
  • 936 views

Badge +2

I am trying to add a button to the context menu for widgets, here is the code:

 miro.onReady(async (): Promise<void> => {
miro.initialize({
extensionPoints: {
getWidgetMenuItems: (widgets) => {
if (widgets[0]['type'] === 'CARD')
return [{
tooltip: 'Estimate',
svgIcon: '<circle cx="12" cy="12" r="9" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
onClick: async (widgets) => {
await jiraCard()
}
}]
}
},
});
})

Unfortunately, this gives me the error 

      TS2322: Type '(widgets: IWidget[]) => { tooltip: string; svgIcon: string; onClick: (widgets: any) => Promise<void>; }[] | undefined' is not assignable to type '(widgets: IWidget[], editMode: boolean) => Promise<IWidgetMenuItem | IWidgetMenuItem[]>'.

  Type '{ tooltip: string; svgIcon: string; onClick: (widgets: any) => Promise<void>; }[] | undefined' is not assignable to type 'Promise<IWidgetMenuItem | IWidgetMenuItem[]>'.

    Type 'undefined' is not assignable to type 'Promise<IWidgetMenuItem | IWidgetMenuItem[]>'.

I’m not sure why this error is happening, as I’m following what I saw on this forum. Does anyone have any advice?

icon

Best answer by Anthony Roux 26 May 2021, 12:32

Hi @manavb1,

 

You can use this simple example:

 

miro.onReady(async () => {
miro.initialize({
extensionPoints: {
getWidgetMenuItems: (widgets) => {
if (widgets[0]['type'] === 'CARD')
return [{
tooltip: 'Estimate',
svgIcon: '<circle cx="12" cy="12" r="9" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
onClick: async (widgets) => {
await miro.showNotification("Hello!");
}
}]
}
},
});
})

 

View original

1 reply

Userlevel 4
Badge +6

Hi @manavb1,

 

You can use this simple example:

 

miro.onReady(async () => {
miro.initialize({
extensionPoints: {
getWidgetMenuItems: (widgets) => {
if (widgets[0]['type'] === 'CARD')
return [{
tooltip: 'Estimate',
svgIcon: '<circle cx="12" cy="12" r="9" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
onClick: async (widgets) => {
await miro.showNotification("Hello!");
}
}]
}
},
});
})

 

Reply