Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/src/configs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export interface DemoConfig {
authorUrl: string;
lovelace: (localize: LocalizeFunc) => LovelaceConfig;
entities: (localize: LocalizeFunc) => Entity[];
theme: () => { [key: string]: string } | null;
theme: () => Record<string, string> | null;
}
4 changes: 2 additions & 2 deletions src/common/dom/apply_themes_on_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { rgbContrast } from "../color/rgb";

interface ProcessedTheme {
keys: { [key: string]: "" };
styles: { [key: string]: string };
styles: Record<string, string>;
}

let PROCESSED_THEMES: { [key: string]: ProcessedTheme } = {};
let PROCESSED_THEMES: Record<string, ProcessedTheme> = {};

/**
* Apply a theme to an element by setting the CSS variables on it.
Expand Down
2 changes: 1 addition & 1 deletion src/common/dom/dynamic-element-directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { directive, NodePart, Part } from "lit-html";

export const dynamicElement = directive(
(tag: string, properties?: { [key: string]: any }) => (part: Part): void => {
(tag: string, properties?: Record<string, any>) => (part: Part): void => {
if (!(part instanceof NodePart)) {
throw new Error(
"dynamicElementDirective can only be used in content bindings"
Expand Down
2 changes: 1 addition & 1 deletion src/common/translations/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const computeLocalize = async (
export const localizeKey = (
localize: LocalizeFunc,
key: string,
placeholders?: { [key: string]: string }
placeholders?: Record<string, string>
) => {
const args: [string, ...string[]] = [key];
if (placeholders) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/url/search-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const extractSearchParamsObject = (): { [key: string]: string } => {
export const extractSearchParamsObject = (): Record<string, string> => {
const query = {};
const searchParams = new URLSearchParams(location.search);
for (const [key, value] of searchParams.entries()) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ha-form/ha-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface HaFormSelectSchema extends HaFormBaseSchema {

export interface HaFormMultiSelectSchema extends HaFormBaseSchema {
type: "multi_select";
options?: { [key: string]: string } | string[] | Array<[string, string]>;
options?: Record<string, string> | string[] | Array<[string, string]>;
}

export interface HaFormFloatSchema extends HaFormBaseSchema {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ha-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ checkCacheVersion();

const debouncedWriteCache = debounce(() => writeCache(chunks), 2000);

const cachedIcons: { [key: string]: string } = {};
const cachedIcons: Record<string, string> = {};

@customElement("ha-icon")
export class HaIcon extends LitElement {
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/ha-locations-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class HaLocationsEditor extends LitElement {

private _locationMarkers?: { [key: string]: Marker | Circle };

private _circles: { [key: string]: Circle } = {};
private _circles: Record<string, Circle> = {};

public fitMap(): void {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/data/config_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const fetchConfigFlow = (hass: HomeAssistant, flowId: string) =>
export const handleConfigFlowStep = (
hass: HomeAssistant,
flowId: string,
data: { [key: string]: any }
data: Record<string, any>
) =>
hass.callApi<DataEntryFlowStep>(
"POST",
Expand Down
2 changes: 1 addition & 1 deletion src/data/conversation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HomeAssistant } from "../types";

interface ProcessResults {
card: { [key: string]: { [key: string]: string } };
card: { [key: string]: Record<string, string> };
speech: {
[SpeechType in "plain" | "ssml"]: { extra_data: any; speech: string };
};
Expand Down
14 changes: 7 additions & 7 deletions src/data/data_entry_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface DataEntryFlowProgress {
handler: string;
step_id: string;
context: {
title_placeholders: { [key: string]: string };
title_placeholders: Record<string, string>;
[key: string]: any;
};
}
Expand All @@ -25,8 +25,8 @@ export interface DataEntryFlowStepForm {
handler: string;
step_id: string;
data_schema: HaFormSchema[];
errors: { [key: string]: string };
description_placeholders: { [key: string]: string };
errors: Record<string, string>;
description_placeholders: Record<string, string>;
}

export interface DataEntryFlowStepExternal {
Expand All @@ -35,7 +35,7 @@ export interface DataEntryFlowStepExternal {
handler: string;
step_id: string;
url: string;
description_placeholders: { [key: string]: string };
description_placeholders: Record<string, string>;
}

export interface DataEntryFlowStepCreateEntry {
Expand All @@ -47,15 +47,15 @@ export interface DataEntryFlowStepCreateEntry {
// Config entry ID
result: string;
description: string;
description_placeholders: { [key: string]: string };
description_placeholders: Record<string, string>;
}

export interface DataEntryFlowStepAbort {
type: "abort";
flow_id: string;
handler: string;
reason: string;
description_placeholders: { [key: string]: string };
description_placeholders: Record<string, string>;
}

export interface DataEntryFlowStepProgress {
Expand All @@ -64,7 +64,7 @@ export interface DataEntryFlowStepProgress {
handler: string;
step_id: string;
progress_action: string;
description_placeholders: { [key: string]: string };
description_placeholders: Record<string, string>;
}

export type DataEntryFlowStep =
Expand Down
4 changes: 2 additions & 2 deletions src/data/hassio/hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export interface HassioHardwareAudioDevice {

interface HassioHardwareAudioList {
audio: {
input: { [key: string]: string };
output: { [key: string]: string };
input: Record<string, string>;
output: Record<string, string>;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const LINE_ATTRIBUTES_TO_KEEP = [
export interface LineChartState {
state: string;
last_changed: string;
attributes?: { [key: string]: any };
attributes?: Record<string, any>;
}

export interface LineChartEntity {
Expand Down
2 changes: 1 addition & 1 deletion src/data/options_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const fetchOptionsFlow = (hass: HomeAssistant, flowId: string) =>
export const handleOptionsFlowStep = (
hass: HomeAssistant,
flowId: string,
data: { [key: string]: any }
data: Record<string, any>
) =>
hass.callApi<DataEntryFlowStep>(
"POST",
Expand Down
6 changes: 3 additions & 3 deletions src/data/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export interface ScriptConfig {

export interface EventAction {
event: string;
event_data?: { [key: string]: any };
event_data_template?: { [key: string]: any };
event_data?: Record<string, any>;
event_data_template?: Record<string, any>;
}

export interface ServiceAction {
service: string;
entity_id?: string;
data?: { [key: string]: any };
data?: Record<string, any>;
}

export interface DeviceAction {
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/config-flow/show-dialog-data-entry-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface FlowConfig {
handleFlowStep(
hass: HomeAssistant,
flowId: string,
data: { [key: string]: any }
data: Record<string, any>
): Promise<DataEntryFlowStep>;

deleteFlow(hass: HomeAssistant, flowId: string): Promise<unknown>;
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/config-flow/step-flow-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class StepFlowForm extends LitElement {
private _loading = false;

@property()
private _stepData?: { [key: string]: any };
private _stepData?: Record<string, any>;

@property()
private _errorMsg?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/external_app/external_messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type ExternalMessage = ExternalMessageResult | ExternalMessageResultError;
export class ExternalMessaging {
public commands: { [msgId: number]: CommandInFlight } = {};

public cache: { [key: string]: any } = {};
public cache: Record<string, any> = {};

public msgId = 0;

Expand Down
6 changes: 3 additions & 3 deletions src/fake_data/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export class Entity {

public state: string;

public baseAttributes: HassEntityAttributeBase & { [key: string]: any };
public baseAttributes: HassEntityAttributeBase & Record<string, any>;

public attributes: HassEntityAttributeBase & { [key: string]: any };
public attributes: HassEntityAttributeBase & Record<string, any>;

public hass?: any;

Expand All @@ -39,7 +39,7 @@ export class Entity {
this.attributes = baseAttributes;
}

public async handleService(domain, service, data: { [key: string]: any }) {
public async handleService(domain, service, data: Record<string, any>) {
// eslint-disable-next-line
console.log(
`Unmocked service for ${this.entityId}: ${domain}/${service}`,
Expand Down
4 changes: 2 additions & 2 deletions src/fake_data/provide_hass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type MockRestCallback = (
hass: MockHomeAssistant,
method: string,
path: string,
parameters: { [key: string]: any } | undefined
parameters: Record<string, any> | undefined
) => any;

export interface MockHomeAssistant extends HomeAssistant {
Expand All @@ -35,7 +35,7 @@ export interface MockHomeAssistant extends HomeAssistant {
);
mockAPI(path: string | RegExp, callback: MockRestCallback);
mockEvent(event);
mockTheme(theme: { [key: string]: string } | null);
mockTheme(theme: Record<string, string> | null);
}

export const provideHass = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class HaDeviceAction extends LitElement {

private _extraFieldsData = memoizeOne(
(action: DeviceAction, capabilities: DeviceCapabilities) => {
const extraFieldsData: { [key: string]: any } = {};
const extraFieldsData: Record<string, any> = {};
capabilities.extra_fields.forEach((item) => {
if (action[item.name] !== undefined) {
extraFieldsData![item.name] = action[item.name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class HaDeviceCondition extends LitElement {

private _extraFieldsData = memoizeOne(
(condition: DeviceCondition, capabilities: DeviceCapabilities) => {
const extraFieldsData: { [key: string]: any } = {};
const extraFieldsData: Record<string, any> = {};
capabilities.extra_fields.forEach((item) => {
if (condition[item.name] !== undefined) {
extraFieldsData![item.name] = condition[item.name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class HaDeviceTrigger extends LitElement {

private _extraFieldsData = memoizeOne(
(trigger: DeviceTrigger, capabilities: DeviceCapabilities) => {
const extraFieldsData: { [key: string]: any } = {};
const extraFieldsData: Record<string, any> = {};
capabilities.extra_fields.forEach((item) => {
if (trigger[item.name] !== undefined) {
extraFieldsData![item.name] = trigger[item.name];
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/cards/hui-history-graph-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {

private _configEntities?: EntityConfig[];

private _names: { [key: string]: string } = {};
private _names: Record<string, string> = {};

private _cacheConfig?: CacheConfig;

Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/cards/hui-map-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class HuiMapCard extends LitElement implements LovelaceCard {

private _mapPaths: Array<Polyline | CircleMarker> = [];

private _colorDict: { [key: string]: string } = {};
private _colorDict: Record<string, string> = {};

private _colorIndex = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/panels/lovelace/entity-rows/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface EntityFilterEntityConfig extends EntityConfig {
}
export interface DividerConfig {
type: "divider";
style: { [key: string]: string };
style: Record<string, string>;
}
export interface SectionConfig {
type: "section";
Expand All @@ -38,7 +38,7 @@ export interface TextConfig {
export interface CallServiceConfig extends EntityConfig {
type: "call-service";
service: string;
service_data?: { [key: string]: any };
service_data?: Record<string, any>;
action_name?: string;
}
export interface ButtonRowConfig extends EntityConfig {
Expand Down
10 changes: 5 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export interface Theme {
export interface Themes {
default_theme: string;
default_dark_theme: string | null;
themes: { [key: string]: Theme };
themes: Record<string, Theme>;
darkMode: boolean;
}

Expand Down Expand Up @@ -188,7 +188,7 @@ export interface Notification {
}

export interface Resources {
[language: string]: { [key: string]: string };
[language: string]: Record<string, string>;
}

export interface Context {
Expand All @@ -204,7 +204,7 @@ export interface ServiceCallResponse {
export interface ServiceCallRequest {
domain: string;
service: string;
serviceData?: { [key: string]: any };
serviceData?: Record<string, any>;
}

export interface HomeAssistant {
Expand Down Expand Up @@ -248,9 +248,9 @@ export interface HomeAssistant {
callApi<T>(
method: "GET" | "POST" | "PUT" | "DELETE",
path: string,
parameters?: { [key: string]: any }
parameters?: Record<string, any>
): Promise<T>;
fetchWithAuth(path: string, init?: { [key: string]: any }): Promise<Response>;
fetchWithAuth(path: string, init?: Record<string, any>): Promise<Response>;
sendWS(msg: MessageBase): void;
callWS<T>(msg: MessageBase): Promise<T>;
loadBackendTranslation(
Expand Down