Implicit constructor definition for derived class

Topics: General
Feb 21, 2013 at 12:13 AM
Edited Feb 21, 2013 at 12:13 AM
I'm using TypeScript 0.8.2 plugin in Visual Studio 2012 Express. When I try the following code I get this error: "Supplied parameters do not match any signature of call target", but this error is not produced in TypeScript Playground.
class A {
    constructor(a) {
    }
}

class B extends A {
}

var b = new B("input");
I could only pass the error if constructor is explicitly defined in class B.
class B extends A {
    constructor(a) {
        super(a);
    }
}
Am I supposed to get this error?

Thanks,
Omid
Coordinator
Feb 21, 2013 at 12:47 AM
The behavior you see in the playground is the intended behavior -- the constructor should be getting automatically defined. I don't see this with the latest sources from the develop branch, so you should see this fixed in the next release (0.8.3.0).
Feb 21, 2013 at 1:12 AM
You're right, the code above does not reproduce it. But it reproduces when bringing initialization before class definitions.
var b = new B("input");

class A {
    constructor(a) {
    }
}

class B extends A {
}
I know why this would fail in JS, but it would be great if TS could reorder the calls in the order of dependencies, or at least produce a more helpful error message in this case.
Feb 21, 2013 at 1:27 AM
Edited Feb 21, 2013 at 1:43 AM
The error in the above code snippet looks like to be a bug because the following works just fine:
var b = new B("input");

class A {
    constructor(a) {
    }
}

class B extends A {
    constructor(a) {
        super(a);
    }   
}
Feb 21, 2013 at 8:41 PM