rokucommunity/brighterscript

Support more specific types on component interface fields

Opened this issue ยท 3 comments

When we define component interfaces, we should support more specific types that can further improve the type system.

<component name="MyComponent">
    <interface>
        <field id="someNode" type="MAKE_ME_MORE_AWESOME" />
    </interface>
</component>
  1. More specific component types instead of the generic node:
    Instead of
<field id="someNode" type="node" />

We could support

<field id="someNode" type="roSGNodeContentNode" />
  1. enums instead of strings or integers
    Instead of
<field id="someNode" type="SomeInterface" />

Could be

enum RemoteDirection
    up="up
    down="down"
end interface
<field id="direction" type="RemoteDirection" />

and much more. There are many edge cases to work out here. We could start with component types, and expand upon it later.

Nice! A lot of options. I was thinking something way simpler though, and I just tried something and it worked!

<component name="MyComponent">
    <interface>
        <!-- someNode is supposed to be of type Label -->
        <field id="label" type="node" />
    </interface>
</component>

We can do something like

interface MyComponent extends roSGNodeMyComponent
    label as roSGNodeLabel
end interface

And now I have a type that actually has better typing on the field

I think @TwitchBronBronโ€™s idea is totally doable for v1.1 ๐Ÿ˜‰

I really want this now. ๐Ÿ‘

I may work on it if I have time.