Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more specific types on component interface fields #1262

Open
TwitchBronBron opened this issue Jul 25, 2024 · 3 comments
Open

Support more specific types on component interface fields #1262

TwitchBronBron opened this issue Jul 25, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@TwitchBronBron
Copy link
Member

TwitchBronBron commented Jul 25, 2024

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.

@TwitchBronBron TwitchBronBron added the enhancement New feature or request label Jul 25, 2024
@TwitchBronBron TwitchBronBron changed the title Support more specific component types in node fields Support more specific types on component interface fields Jul 25, 2024
@iBicha
Copy link
Contributor

iBicha commented Jul 25, 2024

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

@markwpearce
Copy link
Collaborator

I think @TwitchBronBron’s idea is totally doable for v1.1 😉

@markwpearce
Copy link
Collaborator

I really want this now. 👍

I may work on it if I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants