Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
How to make RTCPeerConnection be available in Kotlin/JS without declaring the class myself?

I am trying out Kotlin/JS.

As an exercice to learn something new I wanted to mess with WebRTC. I've been following the basic examples on their site and at some point you have to instantiate an object from the RTCPeerConnection class. Something very straight forward and available without installing any dependencies.

If I come on the browser's console I can easily do:

Browser screenshot

However in my IntelliJ the compiler screams at me stating that there is no such class so I can't instantiate it.

Now I know of two ways I could get around to this:

  1. Using fun js(code: String): dynamic, which works but I lose all intelli-sense and type-safety making me really sad (and kind of missing the point of using Kotlin)
  2. Declaring (using external keyword) the entirety of the RTC spec which is very extense and that also makes me really sad

I've found out a way to hack my way around the second approach but still is not good enough:

I've installed @types/webrtc from NPM in this fashion:

implementation(npm("@types/webrtc", "0.0.30", generateExternals=true))

So I could trick Dukat to generate the external declarations for me and I've actually succeeded!

… or that's what I thought

Error

Yeah, seems like they've declared the RTCPeerConnection as an interface and not as a class so I am out of luck

Has somebody worked this out of it?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!