Closed leerenbo closed 1 month ago
type JointContent = React.ReactNode | ArgsProps
It's means that JointContent
is parent of ReactNode
;)
@leerenbo please close issues, when you receive answer on your question or no more action required ;)
I understand what you parent mean. But I can't express it in Kotlin external definitions.
type JointContent = React.ReactNode | ArgsProps
How can we describe the above types?
I use inheritance to keep the property mapping correct and abandon the relationship between properties.
external interface JointContent :ArgsProps,react.ReactNode
I think is the most appropriate declaration.
external interface ReacNode : JointContent
Is what you need in fact ;)
For pill please check ReactNode
(it's also union) factory functions
What! Why can inheritance relationships be declared outside a class? Is there some document that I haven't read?
In TS:
type A = B | C
In Kotlin
sealed interface A
interface B : A
interface C : A
Did I understand it wrong?
Is there some document that I haven't read?
kotlin-cssom-core
sources - probably best variant :)
You need adapter for ReactNode
On Tue, Sep 17, 2024, 20:09 LeeRenBo @.***> wrote:
image.png (view on web) https://github.com/user-attachments/assets/f8576d2f-2b8a-4226-8875-a8a2bc41cbbb
Did I understand it wrong?
— Reply to this email directly, view it on GitHub https://github.com/JetBrains/kotlin-wrappers/issues/2519#issuecomment-2356470290, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACL3NQ3IAW7LFHHDOE5JFOTZXBO47AVCNFSM6AAAAABOLYQSSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJWGQ3TAMRZGA . You are receiving this because you commented.Message ID: @.***>
Union types ,It is mentioned in this document, I understand parent mean. https://github.com/karakum-team/karakum/blob/master/docs/blogposts/Open_issues.md
ReactNode is react.ReactNode in kotlin-react-core. If completely following the definition, I need to copy the entire kotlin-react-core in and then make fine adjustments.
Previously, I never thought of modifying kotlin-react-core, so I used inheritance mapping property.
Please check ReactNode implementation - it contains all required pills.
Copies isn't required
type JointContent = React.ReactNode | ArgsProps
external interface JointContent;
inline fun JointContent(
source: react.ReactNode,
): JointContent = source.unsafeCast<JointContent>()
inline fun JointContent(
source: ArgsProps,
): JointContent = source.unsafeCast<JointContent>()
I seem to understand a little bit.Is this correct?
If ArgsProps are in the same subproject - union type is parent
external interface JointContent;
inline fun JointContent(
source: react.ReactNode,
): JointContent = source.unsafeCast<JointContent>()
external interface ArgsProps : react.Props, JointContent {
...
got it.
I have made a lot of efforts to use the unified Kotlin language for whole web applications. When wrapping the Antd UI, for the first time, I want to give up.
In order to write this wrapper, I looked at the wrapper of MUI which has a hard mapping with the hierarchical matching. I read the source code of Karakum, learned about TS's AST, and wrote several Karakum plugins.
Still , Inaccurate type mapping makes me very frustrated. Pick, Omit, Partial... Union Type... are language level not supported.
In order to ensure the accuracy of the definition in .kt, I may raise many “non-sealed” issues.
When writing the wrapper for antd's
A type
JointContent
Union fromReact.ReactNode | ArgsProps
. react.ReactNode is sealed.https://github.com/ant-design/ant-design/blob/aa48a3cf4223a422be9d17f4aed2e9fb3aae1003/components/message/interface.ts#L47