I haven’t the first clue or understanding of the new backoffice. I’d prefer not to use TypeScript at all but here I am. I’m struggling with these types and I wonder if anyone could help me piece this particular code together:
As I understand it, consumeContext is providing me UmbTreeItemContext back.
The property parentTreeItem should not exist on this object, but it does.
I can ignore the warning and my code works just fine, but what I don’t understand is why this object returned to me from consumeContext appears to have properties and methods from UmbTreeItemContextBase.
The way these are named, it’s no surprise to me. But it seems to be a surprise to the TypeScript compiler. And the documentation site reads like stereo instructions, but I can’t find the relationship between UmbTreeItemContext and UmbTreeItemContextBase myself either.
I’m sure this is wrong. It feels wrong. And it’s frustrating that none of the code above came from anything my TS language service in the IDE suggested.
For starters I prefer not to use typescript strikes me as odd because it will drastically improve code quality and avoid a lot of surprises runtime. I understand it can be frustration if you don’t understand everything, but I highly recommend you learn to use it well.
UmbTreeItemContext is an interface, so I guess your instance is an object that has that interface. The UmbTreeItemContextBase implements this interface so it’s very much possible that the instance you get is actually of type UmbTreeItemContextBase. So your IDE is correct to not give you the parentTreeItemContext property, since it’s not on the interface.
Now I’m not expert, so I don’t know if there are any implications for casting to UmbTreeItemContextBase. Usually it’s not without reason to abstract certain things to interfaces. I’ll let someone who knows more about the inner workings answer that
Why do you need the parentTreeItemContext? What does it do?