From 429426e7f756911c39be5d6ffb11e26e31bf570a Mon Sep 17 00:00:00 2001 From: Denys Dovhan Date: Fri, 9 Jun 2023 19:03:35 +0300 Subject: [PATCH] fix: no implicit any --- src/editor.ts | 12 +++++++----- src/localize.ts | 8 +++++++- src/vacuum-card.ts | 8 +++++--- tsconfig.json | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/editor.ts b/src/editor.ts index 0f7e3083..dde351a3 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -11,7 +11,7 @@ import { Template, VacuumCardConfig } from './types'; import styles from './editor.css'; type ConfigElement = HTMLInputElement & { - configValue?: string; + configValue?: keyof VacuumCardConfig; }; @customElement('vacuum-card-editor') @@ -58,7 +58,7 @@ export class VacuumCardEditor extends LitElement implements LovelaceCardEditor { @selected=${this.valueChanged} .configValue=${'entity'} .value=${this.config.entity} - @closed=${(e) => e.stopPropagation()} + @closed=${(e: Event) => e.stopPropagation()} fixedMenuPosition naturalMenuWidth required @@ -78,7 +78,7 @@ export class VacuumCardEditor extends LitElement implements LovelaceCardEditor { @selected=${this.valueChanged} .configValue=${'map'} .value=${this.config.map} - @closed=${(e) => e.stopPropagation()} + @closed=${(e: Event) => e.stopPropagation()} fixedMenuPosition naturalMenuWidth > @@ -169,7 +169,10 @@ export class VacuumCardEditor extends LitElement implements LovelaceCardEditor { return; } const target = event.target as ConfigElement; - if (!target.configValue || this[target.configValue] === target?.value) { + if ( + !target.configValue || + this.config[target.configValue] === target?.value + ) { return; } if (target.configValue) { @@ -183,7 +186,6 @@ export class VacuumCardEditor extends LitElement implements LovelaceCardEditor { }; } } - console.log('new config', this.config); fireEvent(this, 'config-changed', { config: this.config }); } diff --git a/src/localize.ts b/src/localize.ts index 17979318..cae095cd 100644 --- a/src/localize.ts +++ b/src/localize.ts @@ -29,7 +29,13 @@ import * as tw from './translations/tw.json'; import * as uk from './translations/uk.json'; import * as vi from './translations/vi.json'; -const languages = { +type Translations = { + [key: string]: { + [key: string]: string; + }; +}; + +const languages: Record = { ca, cn, cs, diff --git a/src/vacuum-card.ts b/src/vacuum-card.ts index 9efe206a..a2be4810 100755 --- a/src/vacuum-card.ts +++ b/src/vacuum-card.ts @@ -6,6 +6,7 @@ import { HomeAssistant, ServiceCallRequest, } from 'custom-card-helpers'; +// @ts-ignore import registerTemplates from 'ha-template'; import get from 'lodash/get'; import localize from './localize'; @@ -197,7 +198,7 @@ export class VacuumCard extends LitElement {
- ${localize(`source.${source}`) || source} + ${localize(`source.${source.toLowerCase()}`) || source}
${sources.map( @@ -208,7 +209,7 @@ export class VacuumCard extends LitElement { value=${item} @click=${this.handleSpeed} > - ${localize(`source.${item}`) || item} + ${localize(`source.${item.toLowerCase()}`) || item} ` )} @@ -317,7 +318,8 @@ export class VacuumCard extends LitElement { private renderStatus(): Template { const { status } = this.getAttributes(this.entity); - const localizedStatus = localize(`status.${status}`) || status; + const localizedStatus = + localize(`status.${status.toLowerCase()}`) || status; if (!this.config.show_status) { return nothing; diff --git a/tsconfig.json b/tsconfig.json index d2b17065..c603c939 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "strict": true, - "noImplicitAny": false, + "noImplicitAny": true, "skipLibCheck": true, "resolveJsonModule": true, "experimentalDecorators": true,