How can i check whether a decoration object is of type widget or inline

How can i check whether a decoration object is of type widget or inline. I filter a decoration from set as

const filteredDecos = this.decorationSet.find().filter((decoration: any) => {
      const { spec: annotationSpec } = decoration
      return annotationSpec.annotationId === annotationId

For inline, a decoration that is pushed into decoration set is created as

const newDeco = Decoration.inline(
        class: classNames.join(' '),
        annotationId: annotationId,

And for a decoration created using widget static method :

        (view, getPos) =>
          key: annotationId,
          ignoreSelection: true,

From the array of filteredDecos, I need need to determine if a decoration is created using inline or widget static methods. I checked the object in console, say filteredDecos[0] which is has a key type of WidgetType. Accessing filteredDecos[0].type, gives error that ‘type’ property doesnot exist on Decoration. I have filteredDecos[0].inline as false in browser console, but when coding this condition, I get typescript error:

Property 'inline' does not exist on type 'Decoration'. Did you mean to access the static member 'Decoration.inline' instead?ts(2576)

You can’t. But you can check the content of its spec object to see what kind of stuff you put in there when you created it.

1 Like

Yes, I figured that out last night and I’m currently adding additional data in spec for inline decoration to differentiate it from widget decoration.