Skip to content

Commit 773b486

Browse files
authoredMar 15, 2025··
refactor: Remove unnecessary schemaForType (#1960)
1 parent 75ae772 commit 773b486

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed
 

‎src/config/types.ts

+7-18
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,6 @@ export type ViewDisplayConfig = z.infer<typeof viewDisplaySchema>;
116116
// Stock Actions
117117
// *************************************************************************
118118

119-
// Declare schemas for existing types.
120-
// See: https://github.com/colinhacks/zod/issues/372#issuecomment-826380330
121-
const schemaForType =
122-
<T>() =>
123-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
124-
<S extends z.ZodType<T, any, any>>(arg: S) => {
125-
return arg;
126-
};
127-
128119
// https://www.home-assistant.io/dashboards/actions/#options-for-confirmation
129120
const actionBaseSchema = z.object({
130121
confirmation: z
@@ -153,15 +144,13 @@ const toggleActionSchema = actionBaseSchema.extend({
153144
});
154145
export type ToggleActionConfig = z.infer<typeof toggleActionSchema>;
155146

156-
const targetSchema = schemaForType<HassServiceTarget>()(
157-
z.object({
158-
entity_id: z.string().or(z.string().array()).optional(),
159-
device_id: z.string().or(z.string().array()).optional(),
160-
area_id: z.string().or(z.string().array()).optional(),
161-
floor_id: z.string().or(z.string().array()).optional(),
162-
label_id: z.string().or(z.string().array()).optional(),
163-
}),
164-
);
147+
const targetSchema: z.ZodSchema<HassServiceTarget, z.ZodTypeDef> = z.object({
148+
entity_id: z.string().or(z.string().array()).optional(),
149+
device_id: z.string().or(z.string().array()).optional(),
150+
area_id: z.string().or(z.string().array()).optional(),
151+
floor_id: z.string().or(z.string().array()).optional(),
152+
label_id: z.string().or(z.string().array()).optional(),
153+
});
165154

166155
const performActionActionSchema = actionBaseSchema.extend({
167156
action: z.literal('perform-action'),

0 commit comments

Comments
 (0)
Please sign in to comment.