07/06/2022, 9:21 AM
Hey peeps! After upgrading Kotlin from 1.6.10 to 1.6.21 recently, our exported TypeScript definitions are broken for some cases. It’s mostly about Kotlin generating nested comments inside method signatures, e.g.
/* kotlin.collections.List<any/* */> */
). The inner comment closing statement (
) will make the outer comment closing appear as regular code and thus generate a syntax error in TypeScript. I’ll put a slightly more complete example in the thread. Did anyone have any issues like that, or is there any related entry in the issue tracker? I haven’t found anything so far, but can’t imagine that I’m the only one with totally broken TypeScript definitions. 🤔
Shortened example: Kotlin class:
public class Manager(
  private var proxyKey: String,
  private var countryAlpha2: String,
) {
  public companion object {
    public fun build(proxyKey: ProxyKey, countryAlpha2: String): Manager =
      Manager(, countryAlpha2)

  public fun currentAnswers(): List<ApiAnswer> {
    return someSerializer.convertResponseToApiAnswers(response)
Generated Typescript definition (
export namespace {
    class Manager {
        constructor(proxyKey: string, countryAlpha2: string);
        static get Companion(): {
            build(proxyKey: any/* */, countryAlpha2: string):;
        currentAnswers(): any/* kotlin.collections.List<any/* */> */;
→ The nested comments inside the method signature of
are not valid TypeScript syntax and break everything that comes after the
Ok, looks like this was actually fixed in Kotlin 1.7.0. I’ve updated my issue in the issue tracker.