Currently experimenting with Polymer 3 preview to explore how it can be integrated into our team workflow.
The recommended method for declaring an element in v3 is as follows:
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
...
class MyElement extends PolymerElement {
...
}
For more information, visit: https://www.polymer-project.org/blog/2018-03-23-polymer-3-latest-preview.html
While this approach works smoothly with typescript for basic functionalities, it does not recognize that the class MyElement extends HTMLElement. As a result, attempting to use this.dispatchEvent(...) in the code will lead to compilation errors.
I attempted to create a .d.ts file to instruct typescript, but all attempts were unsuccessful.
1) Trying direct typing:
class PolymerElement extends HTMLElement{}
2) Typing the module:
declare module "polymer-element" {
export class PolymerElement extends HTMLElement {}
}
Despite trying several variations, the transpiler does not seem to recognize any of them. Any suggestions?