Thread
#serialization
    pajatopmr

    pajatopmr

    1 year ago
    I am trying to model a TypeScript document using Kotlin. No small challenge. Any suggestions on how to model something like this snippet:
    someProvider?: boolean | string | SomeOptions;
    My current solution is to create a sealed class
    SomeProvider
    with subclasses:
    BooleanProvider
    ,
    StringProvider
    , and
    OptionsProvider
    so that I have the Kotlin snippet,
    someProvider: SomeProvider?
    which works but feels sub-optimal. Alternative suggestions much appreciated.
    andylamax

    andylamax

    1 year ago
    what do you mean when you say you trying to model a TS document? What is your end goal?
    pajatopmr

    pajatopmr

    1 year ago
    That is a way too open question, but I'll be brief: my goal is to replace Jacoco for Kotlin with a better tool that works on the source rather than an intermediate form and to get there it would be good to have a library that supports Microsoft's LSP. Since LSP is specified using TypeScript and since Kotln is my language of choice these days a TypeScript interface to a Kotlin something is necessary. There is LSP4E/J but I'd rather keep it pure Kotlin and eventually get to a MPP final result. While I do enjoy talking about the end goal, the serialization issue at hand will be much more helpful. Have I given you enough information so you can offer a suggestion? You can see some of my early work up on GitLab and the LSP spec is here.