Skip to content

JS example on the first page more verbose than TS version #397

Closed
@LAC-Tech

Description

@LAC-Tech

Javascript version could just be:

import {html, css, LitElement} from 'lit';

export class SimpleGreeting extends LitElement {
  static styles = css`p { color: blue }`;

  static properties = {
    name: {type: String}
  }

  constructor() {
    super();
    this.name = 'Somebody';
  }

  render() {
    return html`<p>Hello, ${this.name}!</p>`;
  }
}

customElements.define('simple-greeting', SimpleGreeting);

Styles and properties don't need to be getter functions, do they? This saves 4 lines and looks a bit nicer.

I get that it's still not as nice as the TS version without decorators, but no need to make it more long-winded than it needs to be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions