Now that the <component interfaces are sealed> I'm...
# react
d
Now that the component interfaces are sealed I'm running into some issues with externals for headlessui. They have some components named
Menu
,
Menu.Item
,
Menu.Button
. I previously had something like this for the externals, but now using
external object
doesn't work since
FunctionComponent
is sealed:
Copy code
external object Menu : FunctionComponent<...> {
    val Item: FunctionComponent<...>
    val Button: FunctionComponent<...>
}
Is there a better way to handle something like this?
😬 1
t
cc @Sergei Grishchenko
Which module annotation do you have for
Menu
?
d
I'm using
@file:JsModule("@headlessui/react")
t
And
@JsName("default")
for
Menu
?
d
Nope, no annotation on menu. I have a bunch of other components in this file as well, just importing
@headlessui/react
will be an object with all of the components
t
Will it work with suppress?
Also
FC
alias is preferable for declarations
d
Haven't tried, not sure what I would put in suppress - it's a compile error:
Headlessui.kt: (43, 26): Inheritance of sealed classes or interfaces from different module is prohibited
Yeah realized that after,
FC
has the same issue since it's just an alias though
t
@file:Suppress("SEALED_INHERITOR_IN_DIFFERENT_MODULE")
d
Ooh yep that works as long as I put it in the
react
package as well
Other option I just tried is having a separate file for the child components, not as nice but it does work as well:
Copy code
@file:JsModule("@headlessui/react")
@file:JsNonModule
@file:JsQualifier("Menu")

package headlessui

import react.FunctionComponent

@JsName("Item")
external val MenuItem: FunctionComponent<MenuItemProps>

@JsName("Button")
external val MenuButton: FunctionComponent<MenuButtonProps>

@JsName("Items")
external val MenuItems: FunctionComponent<MenuItemsProps>
And then keep just
external val Menu: ...
in the original file
t
Suppress
is preferred right now
d
Okay thanks for the help!
t
Because I’m not sure, that
sealed
will stay for
FC
@Daniel Rampelt Thank you for your use case
🎉 1
FYI - Next step:
Copy code
@Deprecated(replaceWith="FC")
typealias FunctionComponent<P> = FC<P>
😈