Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassLike can not extend nested entity #296

Closed
Schahen opened this issue May 29, 2020 · 5 comments
Closed

ClassLike can not extend nested entity #296

Schahen opened this issue May 29, 2020 · 5 comments
Labels
import-qualifiers anything related to JsQualifier, JsModule, JsNonModule annotations and similar constructs kotlin-design limitations due to the design of kotlin language
Milestone

Comments

@Schahen
Copy link
Contributor

Schahen commented May 29, 2020

I was 100% sure that this issue exist however I'm failing to find it, to lost it is worser than to have a duplicate, so, here's a minimal breaking example:

declare class Bluebird<R> implements Bluebird.Inspection<R> {
}

declare namespace Bluebird {
  interface Inspection<R> {
  }
}
external open class Bluebird<R> : Inspection<R> {
    interface Inspection<R>
}

which is translated to:

external open class Bluebird<R> : Inspection<R> {
    interface Inspection<R>
}

This seemingly harmless snippet of code is actually illegal in Kotlin since we can no inherit from nested entities.

Luckily, the workaround exists and it's as easy as just move Inspection out of parent class and us JsQualifier annotation if needed.

@Schahen Schahen added kotlin-design limitations due to the design of kotlin language import-qualifiers anything related to JsQualifier, JsModule, JsNonModule annotations and similar constructs labels May 29, 2020
@Schahen Schahen modified the milestones: 0.5.1, 0.5.2 May 29, 2020
@Schahen Schahen modified the milestones: 0.5.2, 0.5.3 Jun 13, 2020
@Schahen
Copy link
Contributor Author

Schahen commented Jun 19, 2020

Here's how underlying javascript structure supposed to look like:

class Ping {
    ping() {
        console.log("PING");
    }   
}

class Pong {
    pong() {
        console.log("PONG");
    }   
}

Ping.Pong = Pong;
exports.Ping = Ping;

@Schahen
Copy link
Contributor Author

Schahen commented Jun 19, 2020

Funny thing is that I don't know how to mimic exactly this in ts, I know how to do this:

export declare class Ping implements Ping.Pong {
    ping();
    pong();
}

declare namespace Ping {
    interface Pong {
        pong();
    }   
}

but this won't if Ping would have been a class

@Schahen Schahen modified the milestones: 0.5.3, 0.5.8 Jul 21, 2020
@Schahen
Copy link
Contributor Author

Schahen commented Aug 19, 2020

Here's more "pure" js example of such declaration

function Ping() { }
Ping.Pong = function() { }

Ping.prototype = new Ping.Pong();

Ping.prototype.ping = function() {
    console.log("ping!!!");
}

Ping.Pong.prototype.pong = function() {
    console.log("pong!!!");
}

exports.Ping = Ping;

@Schahen
Copy link
Contributor Author

Schahen commented Aug 19, 2020

Minimal typescript example:

export declare class Ping implements Ping.Pong {
    ping();
    pong();
}

declare namespace Ping {
  interface Pong {
      pong();
  }
}

@shabunc
Copy link
Contributor

shabunc commented Aug 20, 2020

I can see a lot of room for improvement but well, know we are resolving this particular situation, so I'm closing this one.

@Schahen Schahen closed this as completed Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import-qualifiers anything related to JsQualifier, JsModule, JsNonModule annotations and similar constructs kotlin-design limitations due to the design of kotlin language
Projects
None yet
Development

No branches or pull requests

2 participants