"Call target does not contain any signature" for call to super() without typings file

I'm trying to make Polymer 2.0 work with Typescript and am running into issues when making a constructor where libraries - including Polymer 2 - do not expose a proper typings file. In the simplest case:

class MyView1 extends Polymer.Element {
    public static is = 'my-view1';

    constructor() {
        super(); // [ts] Call target does not contain any signature
    }
}

To make it compile at all without the constructor, I've done a declare var Polymer: any; in a main .d.ts file.

Now, I have two questions:

  1. How (if at all) can I make typescript ignore this and just assume there's a super constructor it can call?
  2. How (if at all) do I declare a typings file that contains a signature for the super class? I haven't been able to find the right documentation for this (and the various use cases I've run into so far) yet.

You can just expand your declaration to include a constructor in the Element property:

declare var Polymer: {
    Element: {
        new ();
    }
};

For your second question, you can just move this to a *.d.ts file. See the documentation on creating declaration files.

Why

Usually, this is because you there is conditional logic which alters what the superclass can be. For instance --

class A {
    constructor() {
        super(/* anything */);
    }
}
class B {
    constructor() {
        super(/* anything */);
    }
}

var X = { prod: A, qa: A, dev: B, mock: B }[ environment.type ];  // inline map

class C extends X {
    constructor() {
        super(/* anything */);
    }
}

-- can yield this behavior if type is not even declared on environment, or [potentially] if TypeScript especially thinks that X could be something other that a class which takes the arguments being provided by the subclass.

This worked for me:

class MyView1 extends (Polymer.Element as {new(): any}) {
    ...
}