Buslowicz / twc

TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
32 stars 1 forks source link

HTMLElement life-cycle callbacks #121

Closed adaliszk closed 6 years ago

adaliszk commented 6 years ago

When I try to use the HTMLElement life-cycle callbacks then I got errors by TypeScript:

TS2339: Property 'connectedCallback' does not exist on type 'PolymerElement'.
TS2339: Property 'disconnectedCallback' does not exist on type 'PolymerElement'.

Polymer repository has a typescript definition, which might help to implement or ask to release that as a separate: https://github.com/Polymer/polymer/blob/typescript/polymer.d.ts

Buslowicz commented 6 years ago

This is not as simple as one would think. The types you linked to do not work out of the box, and last time I talked with the team about it, they are not (at least for now) going to do anything about those types, as they concentrate on making a generator to automatically generate types. Typings under polymer.d.ts is a copy of previous types on Polymer repo, tweaked a bit by me so they work nicely. I have also tried to fix those types and publish on @types, but they refused to merge my types as I do not own Polymer itself... Ended up with types on this repo (published on npm here). After that I had 3 months of no time for twc, and now forgot to mention that, but will update twc and how to use those types soon (after I am done with making mixins work).

tpluscode commented 6 years ago

Speaking of which: Polymer/polymer#4928

Buslowicz commented 6 years ago

I am still not sure how they want to generate more complex types like mixinBehaviors. Till it's finished and working, I'll stick with separate types for Polymer core.