Hi,
Iâve just started to code a react app with typescript and Iâm struggling with getting some props (ex. âTextâ) from interfaces like IStickerWidget which extends IWidget.Â
interface IWidget extends IWidgetNamespaces {
readonly id: string
readonly type: string
readonly bounds: IBounds
readonly groupId?: string
readonly createdUserId: string
readonly lastModifiedUserId: string
}
Here is the scenario:Â
Iâm using the type declaration miro.d.ts.Â
Here is the snippet code where:
1) I get the widgets selected (through the SDK IBoardSelectionCommands and its get() method),
2) filter by type (STICKER) and
3) then try to get again the specific widget, but through the get command from IBoardWidgetsCommands this time, as I thought the SDK was going to return an IStickerWidget type base on the filterby id.
let selectedWidgets:SDK.IWidgete] = await miro.board.selection.get()
let selectedStickers:Array<SDK.IWidget> = selectedWidgets.filter((widget) => widget.type === 'STICKER')
// As SelectStickers is an IWidgetl],
// I guess by requesting the specific widget by ID I can get back IStickerWidget types
// So then I can call props like "Text"
// Example:
let stickerProp = await miro.board.widgets.get({ id: selectedStickersg0].id })
// however, StickerProp keeps being a IWidget Type
console.log(stickerProp 0].text)
The get() method returns another IWidget Type, which of course doesnât have the prop âTextâ. However, this doesnât happens when you use JS without typescript or in the JS console.Â
Â
Having said the above, has someone experienced the same situation? Any idea to approach this or fix it?
Best,
R.