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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With