From f2120e15f490f599e08a00c768be4dfeeb87718f Mon Sep 17 00:00:00 2001 From: Zack Arnett Date: Mon, 29 Oct 2018 19:29:24 -0400 Subject: [PATCH 1/6] Update Types --- src/panels/lovelace/cards/hui-error-card.ts | 14 ++-- src/panels/lovelace/cards/hui-gauge-card.ts | 21 +++--- src/panels/lovelace/cards/hui-iframe-card.ts | 27 ++++---- .../lovelace/cards/hui-markdown-card.ts | 29 +++++---- .../lovelace/cards/hui-thermostat-card.ts | 64 ++++++++++--------- 5 files changed, 82 insertions(+), 73 deletions(-) diff --git a/src/panels/lovelace/cards/hui-error-card.ts b/src/panels/lovelace/cards/hui-error-card.ts index 758fa43459a7..df367f2301b7 100644 --- a/src/panels/lovelace/cards/hui-error-card.ts +++ b/src/panels/lovelace/cards/hui-error-card.ts @@ -9,11 +9,11 @@ interface Config extends LovelaceConfig { } class HuiErrorCard extends LitElement implements LovelaceCard { - protected config?: Config; + private _config?: Config; static get properties() { return { - config: {}, + _config: {}, }; } @@ -21,19 +21,19 @@ class HuiErrorCard extends LitElement implements LovelaceCard { return 4; } - public setConfig(config): void { - this.config = config; + public setConfig(config: Config): void { + this._config = config; } protected render(): TemplateResult { - if (!this.config) { + if (!this._config) { return html``; } return html` ${this.renderStyle()} - ${this.config.error} -
${this._toStr(this.config.origConfig)}
+ ${this._config.error} +
${this._toStr(this._config.origConfig)}
`; } diff --git a/src/panels/lovelace/cards/hui-gauge-card.ts b/src/panels/lovelace/cards/hui-gauge-card.ts index 6fcd7b4f8536..59efcdf96c5b 100644 --- a/src/panels/lovelace/cards/hui-gauge-card.ts +++ b/src/panels/lovelace/cards/hui-gauge-card.ts @@ -10,6 +10,7 @@ import isValidEntityId from "../../../common/entity/valid_entity_id.js"; import { fireEvent } from "../../../common/dom/fire_event.js"; import "../../../components/ha-card.js"; +import { TemplateResult } from "lit-html"; interface Config extends LovelaceConfig { entity: string; @@ -38,11 +39,11 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { }; } - public getCardSize() { + public getCardSize(): number { return 2; } - public setConfig(config) { + public setConfig(config: Config): void { if (!config || !config.entity) { throw new Error("Invalid card configuration"); } @@ -52,7 +53,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { this._config = { min: 0, max: 100, ...config }; } - protected render() { + protected render(): TemplateResult { if (!this._config || !this.hass) { return html``; } @@ -92,7 +93,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { `; } - protected shouldUpdate(changedProps: PropertyValues) { + protected shouldUpdate(changedProps: PropertyValues): boolean { if (changedProps.get("hass")) { return ( (changedProps.get("hass") as any).states[this._config!.entity] !== @@ -105,7 +106,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { return (changedProps as unknown) as boolean; } - protected updated() { + protected updated(): void { if ( !this._config || !this.hass || @@ -135,7 +136,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { ); } - private renderStyle() { + private renderStyle(): TemplateResult { return html`