andylamax
05/30/2023, 4:03 AMexternal interface UserProps : Props {
var name: String
var photo: String?
}
In Typescript, Rendering a component (say User) with these kind of props would behave like this
✅ Compilation
<User name="John Doe"/>
❌ Compilation (prop name is required)
<User photo="<https://some.url>"/>
While in kotlin
✅ Compilation
User { name="John Doe" }
✅ Compilation, ❌ Runtime
User { photo="<https://some.url>" }
Now (@turansky), Isn't there a way to provide compile time safety for kotlin-react
similar to how Typescript
provides it for jsx
?? I feel like this is so hugely required especially for large projectsspand
05/30/2023, 6:16 AMclass UserProps(val name: String, val photo: String? = null)
andylamax
05/30/2023, 9:36 AMspand
05/30/2023, 9:40 AMandylamax
05/30/2023, 9:52 AMturansky
05/31/2023, 8:29 PMIsn’t there a way to provide compile time safety forIt’s common problem of DSL with required options/propertiessimilar to howkotlin-react
provides it forTypescript
?jsx
andylamax
06/01/2023, 11:42 AMChildrenBuilder
. Despite it not being a true react component, it does work for most (Not all) our use case
Something like this if any one asks
private val User = FC<UserProps> {}
inline ChildrenBuilder.User(name: String, photo: String?=null) = User {
this.name=name
this.photo = photo
}
turansky
06/01/2023, 11:58 AMandylamax
06/01/2023, 11:59 AMturansky
06/01/2023, 12:04 PMMike Dawson
06/01/2023, 1:34 PMandylamax
06/01/2023, 5:11 PM