Getting the yType of any YObject

Good day!

I want to get the names and YTypes of all the shared types in my doc.
This is what I tried to do:

doc.share.forEach((value, key) => {
        var type = value._start.content.type.constructor.name
    });

This is a very hacky way, and it works well for YXmlElements, but not with YArrays.

Is there any consistent/proper method to get the YTypes for all the shared types in my doc?

Thanks,
Mansehej.

Hey @Mansehej

I think you already found a solution. Types are just a view on the shared data. You need to define beforehand how you want to interpret the top-level types (e.g. define “name” as Y.Text: getType(“name”, Y.Text)).

Is there any consistent/proper method to get the YTypes for all the shared types in my doc?

Not really. You are supposed to know beforehand which types exists.