I am looking at the generated type definitions by ...
# javascript
a
I am looking at the generated type definitions by
1.6.20-M1
. I gotta admint,
@JsExport
got the love it truly deserves Kudos to the whole team for such accomplishments. A lot of my issues (infact, all I have reported recently) have been already solved
❤️ 3
a
Excited to try it out!
a
Sadly, one thing makes the types definitions unusable. The generated file exposes companion objects on interfaces as a static getter. while at this moment, Typescript doesn't support static members/methods on interfaces
h
one thing? what about this https://youtrack.jetbrains.com/issue/KT-51205? it makes exporting and using with typescript unusable :D
a
@hfhbd I am failing to reproduce your
external class is mapped to any
problem. Coz to me it works just fine
Copy code
package battleground.problem

@JsExport
external interface User {
    var name: String
    var email: String
}

@JsExport
val pete: User = jso { }
Yields
Copy code
export namespace battleground.problem {
    interface User {
        name: string;
        email: string;
    }
}
export namespace battleground.problem {
    const pete: battleground.problem.User;
}
Also, regarding to the promises problem, I don't have the problem because I don't use promises at all. I use a multiplatform of
Promise
called a
Later
, it can be found here https://github.com/aSoft-Ltd/foundation/tree/master/foundation-runtimes/later
👀 1
h
Use a class
a
Use a class
This code
Copy code
package battleground.problem

@JsExport
external class Promise<T>

@JsExport
val promise: Promise<Unit> = TODO()
generates the following types
Copy code
export namespace battleground.problem {
    class Promise<T> {
        constructor();
    }
}
export namespace battleground.problem {
    const promise: battleground.problem.Promise<void>;
}
Are you sure you tried that on
1.6.20-M1
? However, I have noticed
kotlin.js.Promise<T>
is indeed exported as
any // kotlin.js.Promise<T>
While experimenting on this, I also noticed that
Copy code
@JsExport
external class Promise<T> {
   companion object
}
Does not compile. For it to compile, you either remove the
companion object,
or
@JsExport
You can't seem to have both and make it work
h
Using your own
Promise
class does not work with typescript interoperability, because it is not mapped to
js.Promise
.
a
not when you
copy
the type definition in
kotlin.js.Promise
into a file that is not inside a package. This is indeed a workaround though
g
What's the point to use
@JsExport
and
external
on the same class? It's just for testing 1.6.20-M1 or I'm missing something?
a
What's the point to use 
@JsExport
 and 
external
 on the same class?
If you just declare it as
external
the generated
.d.ts
won't include its definitions.
@JsExport
makes your external class types available in the generated
.d.ts
🙏 1