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

Bad types for built-in SpecialKeys #427

Open
znotfireman opened this issue Feb 26, 2025 · 0 comments
Open

Bad types for built-in SpecialKeys #427

znotfireman opened this issue Feb 26, 2025 · 0 comments
Labels
broken Something isn't right not ready - evaluating Currently gauging feedback

Comments

@znotfireman
Copy link
Contributor

It's idiomatic to type children props as [typeof(Fusion.Children)]: Fusion.Child, however this actually becomes [Fusion.SpecialKey]: Fusion.Child which allows for every special key.

Potential fix:

type BuiltinSpecialKey<K, S> = SpecialKey & {
    kind: K,
    -- this isn't necessary but might be useful
    stage: S
}

-- ...

export type Fusion = {
    -- ...
    Children: BuiltinSpecialKey<"Children", "descendants">,
    OnEvent: (eventName: string) -> BuiltinSpecialKey<"OnEvent", "observer">,
    OnChanged: (propertyName: string) -> BuiltinSpecialKey<"OnChanged", "observer">,
    Out: (propertyName: string) -> BuiltinSpecialKey<"Out", "observer">,
    Attribute: (attributeName: string) -> BuiltinSpecialKey<"Attribute", "self">,
    AttributeChanged: (attributeName: string) -> BuiltinSpecialKey<"AttributeChanged", "observer">,
    AttributeOut: (attributeName: string) -> BuiltinSpecialKey<"AttributeOut", "observer">,
    -- ...
}

Or alternatively introduce generics to SpecialKey.

@znotfireman znotfireman added broken Something isn't right not ready - evaluating Currently gauging feedback labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broken Something isn't right not ready - evaluating Currently gauging feedback
Projects
None yet
Development

No branches or pull requests

1 participant