Fusion
Fusion copied to clipboard
Bad types for built-in SpecialKeys
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.