Skip to content

Commit

Permalink
fix: no implicit any
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdovhan committed Jun 9, 2023
1 parent e9d8667 commit 429426e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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
>
Expand Down Expand Up @@ -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) {
Expand All @@ -183,7 +186,6 @@ export class VacuumCardEditor extends LitElement implements LovelaceCardEditor {
};
}
}
console.log('new config', this.config);
fireEvent(this, 'config-changed', { config: this.config });
}

Expand Down
8 changes: 7 additions & 1 deletion src/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Translations> = {
ca,
cn,
cs,
Expand Down
8 changes: 5 additions & 3 deletions src/vacuum-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -197,7 +198,7 @@ export class VacuumCard extends LitElement {
<div slot="trigger">
<ha-icon icon="mdi:fan"></ha-icon>
<span class="icon-title">
${localize(`source.${source}`) || source}
${localize(`source.${source.toLowerCase()}`) || source}
</span>
</div>
${sources.map(
Expand All @@ -208,7 +209,7 @@ export class VacuumCard extends LitElement {
value=${item}
@click=${this.handleSpeed}
>
${localize(`source.${item}`) || item}
${localize(`source.${item.toLowerCase()}`) || item}
</mwc-list-item>
`
)}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"strict": true,
"noImplicitAny": false,
"noImplicitAny": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
Expand Down

0 comments on commit 429426e

Please sign in to comment.