How to use @JsQualifier in Javascript project


I try to use shaka player JS library in my project.
It has example code like this:

var player = new shaka.Player(video);

I’ve read that Javascript doesn’t have packages, so the shaka.Player is made by nested object. OK, I don’t care, but from my Kotlin code I’d like to declare external shaka.Player class with all defined functions so that I can use it from Kotlin code. I’ve read that @JsQualifier is designed for this.

So I made file Player.kt:

external class Player{

And from Kotlin code I use it:

fun test(){
val p = Player()

But it’s still compiled to Javascript code:

function test() {
var p = new Player();

I expect it to emit new shaka.Player() but this is not working.

How can I achieve that “shaka.” prefix before Player class name?

Reference of what I want to bring to Kotlin:


I think compiler generated “import” for your shaka.Player at the start of a module and just used the short name at use sites, like this:

var Player = shaka.Player;
// ...
  function test() {
    var p = new Player();

Please check it.


yes that was exactly the case. It was working this way.