U75957
06/21/2019, 9:45 AMextends
, we get defective inheritance (in short, it does not work). As workaround I do such thing:
class Kotlin : TypeScript() {
init {
tslib.__extends(Kotlin::class.js, TypeScript::class.js)
}
}
Can this be done somehow more elegantly / correctly? I think extending of TS class should be supported by Kotlin/JS. With annotation of external TS class or somehow else.[JB] Shagen
06/21/2019, 12:31 PMU75957
06/21/2019, 12:50 PM__extends
function to extend a class. And it is logical to assume that TypeScript code expects it to be called. I do not know how __extends
works and what it does. You can see it here:
https://www.typescriptlang.org/play/#src=class%20TypeScript%20%7B%20%7D%0D%0A%0D%0Aclass%20Kotlin%20extends%20TypeScript%20%7B%7D
Or read something about it here: https://stackoverflow.com/questions/45954157/understanding-the-extends-function-generated-by-typescript[JB] Shagen
06/21/2019, 12:52 PMU75957
06/21/2019, 12:58 PM[JB] Shagen
06/21/2019, 1:06 PMU75957
06/21/2019, 1:13 PM[JB] Shagen
06/21/2019, 1:16 PMU75957
06/21/2019, 1:36 PMES6
target TypeScript don't generate __extends
function. So looks like __extends
function is just implement some ES6
features.anton.bannykh
06/21/2019, 2:39 PManton.bannykh
06/21/2019, 2:59 PManton.bannykh
06/21/2019, 3:00 PMU75957
06/21/2019, 3:22 PM__extends
will be called for every instance (This is valid only for singleton object
).
I've tried to put this massive list of __extends
calls to top of the app main()
function, but it does not work.anton.bannykh
06/21/2019, 3:25 PManton.bannykh
06/21/2019, 3:44 PMjs("Object").setPrototypeOf(B::class.js, A::class.js)
.anton.bannykh
06/21/2019, 3:45 PM__extends
in the constructor will mess up the prototypal inheritance I thinkanton.bannykh
06/21/2019, 4:16 PManton.bannykh
06/21/2019, 4:39 PMclass B: A()
val dummyB = js("Object").setPrototypeOf(B::class.js, A::class.js)
U75957
06/21/2019, 5:52 PManton.bannykh
06/21/2019, 5:54 PMU75957
06/22/2019, 7:33 AManton.bannykh
06/22/2019, 10:35 AM