Is there a way to disallow extensions on a class? ...
# codereview
s
Is there a way to disallow extensions on a class? Details in 🧵
The most performant way that I’ve found to parse JSON using KotlinJS is to use native
JSON.parse
to produce a
dynamic
, and then
unsafeCast
it to an exported class. This works great, and allows for code sharing across targets (contrasted with
external interface
). This looks like: The problem is that you end up with an incomplete instance of the class, and so if there are extension functions defined on the class, they’ll crash at runtime. I would like to define a
JsExport
class that cannot receive extensions so that users of the class don’t accidentally write code that will crash at runtime!
j
Not exactly what you might want, but you could wrap into value class and avoid auto complete for default extensions 😅