Ts2kt and Partial


#1

I have yet another stupid (maybe) question about kotlin.js. I am trying to create a browser based visualization for one of my JavaFX projects and for that I am using the plotly library`. I can use dynamic type to work with it, but I read about ts2kt tool and decided to try it. I took definitions from DefinitelyTyped.
The conversion completed without errors but with some warnings:

ts2kt version: 0.0.20
Converting index.d.ts
ts2kt: "NamespaceExportDeclaration" kind unsupported yet here! (index.d.ts:1:1 to 11:28)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:119:21 to 120:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:120:35 to 121:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:121:26 to 122:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:122:26 to 123:15)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:123:32 to 124:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:124:26 to 125:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:125:26 to 126:14)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:126:25 to 127:14)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:127:25 to 128:19)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:128:29 to 129:19)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:294:29 to 295:14)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:295:22 to 296:14)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:296:23 to 297:13)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:297:20 to 298:14)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:298:66 to 299:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:299:27 to 300:17)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:301:33 to 302:17)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:302:37 to 303:16)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:303:24 to 304:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:304:38 to 305:15)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:305:35 to 306:23)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:306:32 to 307:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:307:27 to 308:18)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:308:27 to 309:19)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:309:41 to 310:20)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:310:30 to 311:15)
ts2kt: "StringLiteral" kind unsupported yet here! (index.d.ts:311:44 to 312:19)

The problem is that the result contains a lot of Partial class references which is obviously not present in kotlin. Is there a simple way to fix that?


#2

About “StringLiteral” related warnings – unfortunately this declaration use the feature what can’t be expressed in Kotlin now. As an alternative you can add indexer accessor to interfaces when you need to access to members by string name:

external interface ScatterData {
    // ...
    @nativeGetter
    fun get(index: String): Any 
}

///...
data['line.color']

Partial is not supported yet and more over the new version of ts2kt (0.1.0) you will get Any? in such cases.


#3

For now Any is still better because it will compile as is.