Deriving from an external class that is implemented using the Javascript class syntax yields browser error "TypeError: class constructors must be invoked with |new|"


(I tried to file an issue but apparently a new account doesn’t have permission.)


class Foo {
    hello() {
        console.log("Hello from Foo!")


external open class Foo {
    open fun hello()


class Bar : Foo() {
    override fun hello() {
        println("Hello from Bar!")

fun main() {

Result (Firefox):

TypeError: class constructors must be invoked with |new|

This is fixed by replacing Foo.js with:

function Foo() {

Foo.prototype.hello = function() {
    console.log("Hello from Foo!")

(I’d like to attach a file here but seems not supported or no permission.)


The generated code that causes the error is

function Bar() {

The apparent fix is to generate this instead:

function Bar() {
    if (Foo.prototype.hasOwnProperty('constructor')) {
    } else {

Well, the user may have manually created a function named ‘constructor’. Perhaps there is a foolproof way to check whether Foo was defined with the class syntax.


Thank you for reporting this. Kotlin/JS indeed can’t currently extends JS classes. One of the workarounds would be to transpile classes down to ES5.

One normally does have permissions to create a new issue at when they log in with their JetBrains account. Are you logged in as guest? Could you elaborate on problems you have so I can forward it to admin people?


Upon pressing the “Create” button, there’s an error in the lower-right corner saying “Please select a project”. I don’t see a way to select a project, but a tag may be selected (if this is the same thing then the terminology needs to be fixed). However the only kotlin-related tags are

kotlin c interop

none of which appear to be a main kotlin project.

Could the problem be that I made an account at the youtrack site, then logged in here using that account? If the reverse order would have worked then, well, someone who just wants to report an issue wouldn’t know that.