quiro
05/20/2024, 2:18 PM@JsExport enum class Animals { CAT, DOG }
but the typescript definition creates a class that doesn't serialize correctly. I would like the compile-time check here but at runtime it's enough for it to be a string so that it serializes correctly 🤔Artem Kobzar
05/20/2024, 2:50 PMturansky
05/20/2024, 2:57 PMturansky
05/20/2024, 2:58 PMquiro
05/20/2024, 3:03 PMquiro
05/20/2024, 3:18 PMAn exception occurred applying plugin request [id: 'io.github.turansky.seskar', version: '2.66.0']
> Failed to apply plugin class 'seskar.gradle.plugin.SeskarReactPlugin'.
> Configuration with name 'jsMainImplementation' not found.
turansky
05/20/2024, 6:10 PMapply(plugin=...)
in the end of your kts file.quiro
05/20/2024, 8:11 PM@JsExport
annotation I get an error (Declaration of such kind (companion object inside exported interface) can't be exported to JS
)Edoardo Luppi
05/20/2024, 9:18 PMEdoardo Luppi
05/20/2024, 9:20 PMquiro
05/20/2024, 9:39 PMI don't think it's exportableOh, I see. I wanted to provide some enum support so that the consumer of my library could have stronger typing and pass only valid strings to it. I guess the viable alternative is to export an object with the string enum and suggest consumers use it, even if I have to change the type to a string and can only validate it at runtime. For example:
@JsExport
object PetType {
val Dog = "DOG"
val Cat = "CAT"
}
@JsExport
external interface Pet {
val type: String
}
// ts
const pet: Pet = { type: PetType.Dog } // Not sure if you can call it like this
Edoardo Luppi
05/20/2024, 11:14 PMquiro
05/21/2024, 6:14 AMfast-json-stringify
. Because I'm code generating the data model, this is more complicated. That's why some built in way to restrict the options of the consumer of the library would be enough