As a Roblox developer, it is currently too hard to determine whether a particular pseudo-instance exists on an instance.
UI Styling currently allows pseudo-instances to be applied to instances through styles. Multiple pseudo-instances of the same type can be contributed by different styles, and GetStyled() resolves properties from the highest-priority applicable pseudo-instance.
However, there doesn’t seem to be a way to determine whether a particular pseudo-instance type exists on an instance.
For example, calling:
element:GetStyled("CornerRadius", "::UICorner")
when the element has no ::UICorner pseudo-instance, an error occurs:
GetStyled: Selector segment 'UICorner' not found (pseudo-instance does not exist)
This makes it difficult for runtime systems to inspect styled UI components conditionally. One example is custom UI interaction systems that need to account for the geometry of styled element. A hit-testing system may need to determine whether an element has a particular type of psuedo-instance before using GetStyled() to obtain its properties.
If this issue is addressed, it would improve my development experience because I would be able to safely inspect styled UI components at runtime without having to handle errors when a pseudo-instance does not exist.
One possible way to address this could be for GetStyled() to return nil when the requested pseudo-instance does not exist rather than raising an error. Since GetStyled() already returns any, this could preserve the existing API while allowing developers to distinguish between a missing pseudo-instance and a present one whose properties can then be queried.