-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypeScript decorators #7
Comments
Do you mind if I take this one? |
@kenchris sounds great! |
@kenchris still interested in tackling this? |
Yeah, sure |
I have some decorators adapted from the Polymer 2 decorators here: https://stackblitz.com/edit/lit-element-typescript |
I know you guys are working on this. If it's any help, I have most of this in a base class (extended from LitElement) - I've been using in some projects. I was using it often enough to carve it out into a separate package: https://github.com/pshihn/alit-element It doesn't match the exact spec of polymer's decorators, but is very close: @element('alit-card')
export class AlitCard extends AlitElement {
@property() name?: string;
@property() age: number = 30;
@property() description: string = 'This is the default description';
@query('.card')
card?: HTMLDivElement;
@listen('click', '#toggleButton')
toggleBorder() {
this.borderShowing = !this.borderShowing;
this.card.style.border = this.borderShowing ? '2px solid' : 'none';
}
@observe('age', 'description')
ageChanged(records: ChangeRecord[]) {
// do stuff when age or description changes
}
} |
|
I've been using a customized version of @pshihn's decorators and I have to say, I find the |
That's great @kenchris, is Babel7 support on the horizon too? I ran into an issue with Bable7 and decorators here: lit/lit#478 (comment) |
Closing this as a set of decorators has been added. We'll accept separate, new issues for discussion of any new decorators. |
Decorators similar to those in https://github.com/Polymer/polymer-decorators should work well with this base class. They can transform fields into accessors as described in #6.
The text was updated successfully, but these errors were encountered: