Incremental migration of typescript projects to Kotlin

Is there a way to incrementally migrate a TS code base to Kotlin/JS?

A bit of context. I have a Gradle multi-project build which consists of:

  • a Spring Boot server (in Kotlin)
  • a React app (in typescript) built using Create React App and the Gradle node plugin on top of it

I have recently extracted the API client code from the TS subproject into a Kotlin common (multiplatform) subproject of its own.

Now, I’d like to setup a Gradle build for the React app that can depend on the local multiplatform subproject, and that can compile the existing TS files. Is this possible?

(In the end, the goal is to migrate little by little the whole React app to Kotlin)

I’m chiming in as I have a very similar need: We have a JavaScript project (that gets build via Gradle) which shares the data model with some Kotlin code. We currently have duplicated the data model classes in Kotlin and JavaScript code. Instead of doing that, we’d like to rewrite the JavaScript code in Kotlin file-by-file.

Is there a way to setup the kotlin-js plugin in a Gradle project so that if there is JavaScript code present it is taken as-is, and if there is Kotlin code present it is transpiled to JavaScript (via TypeScript), and in the end a single web app out of both sources is build?

Indeed, that’s basically what I’m asking as well.

I’d love to be able to have src/main/kotlin alongside src/main/js and setup Gradle to use both.