Hi! Could anyone please show me (if it's possible)...
# javascript
n
Hi! Could anyone please show me (if it's possible) an example of a TS project using a kotlin lib which uses
@JsExport
? My use case is sharing code between TS frontend and Kotlin/JVM backend, without having to rewrite my frontend in K/JS - right now I am just publishing the
.d.ts
and
.js
fat files and downloading them manually, which is a hack
t
Do you create js target for typings only?
Do you use #serialization?
n
I do use serialisation, but right now I'd just like to be able to use a Kotlin data class in TS. What I did was use the new IR backend and generate an executable, so I get .d.ts definitions (and they work fine)
My question is how can I import those definitions (from a Kotlin lib) in TS easily. Can I publish them with npm for example?
t
Yes, you can publish them
Looks like you don't need Kotlin/JS distribution (output js file). Right?
n
I mean I do in that I need to import the js and .d.ts files from typescript
j
We simply point our package.json to the absolute path
Copy code
"dependencies": {
		"lit-html": "^1.3.0",
		"rez-property-rez-account": "../../../build/library/rez-property-rez-account",
		"rez-property-rez-util": "../../../build/library/rez-property-rez-util",
		"rez-property-rez-dashboard": "../../../build/library/rez-property-rez-dashboard",
		"tslib": "^2.0.1"
	},
In our setup, we use Kotlin on the JVM side and then to build helper methods on the KotlinJS side which the TypeScript project can call So we still build the actual UI in TypeScript +lit-html, but everything else is Kotlin