Hi TS wizards, can you help me to get rid of the c...
# orm-help
k
Hi TS wizards, can you help me to get rid of the cryptic "IDE" error below? The code works just as intended but I don't understand why TS is not satisfied with it.
Copy code
Argument of type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; }' is not assignable to parameter of type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; } & { ...; } & (`Error: Field "${string...'.
  Type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; }' is not assignable to type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; } & { ...; } & `Error: Field "${number}...'.
    Type '{ where: { priority: { in: ("low" | "medium" | "high" | "urgent")[] | null | undefined; }; status: { in: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined; }; }; by: ("projectId" | ... 1 more ... | "priority")[]; _count: true; orderBy: { ...; }; }' is not assignable to type '`Error: Field "${number}" in "orderBy" needs to be provided in "by"`'.ts(2345)
๐Ÿ‘€ 1
a
Hey there! Could you share the
GetGroupedIssuesRequest
and
GetFilteredIssuesRequest
types?
k
Hi @Austin, types are inferred from Zod schema like so:
Copy code
export const PRIORITIES = ['low', 'medium', 'high', 'urgent'] as const
export const STATUSES = [
	'open',
	'in progress',
	'done',
	'in review',
	'canceled',
] as const
export const ALLOWED_GROUP_BY_FIELDS = [
	'status',
	'priority',
	'projectId',
] as const


const filteredIssuesRequestSchema = z.object({
	parentIssueId: z.number().optional().nullable(),
	projectId: z.number().optional().nullable(),
	priority: z.array(z.enum(PRIORITIES)).optional().nullable(),
	status: z.array(z.enum(STATUSES)).optional().nullable(),
})
const groupedIssuesRequestSchema = z.object({
	field: z.enum(ALLOWED_GROUP_BY_FIELDS),
})


export type GetFilteredIssuesRequest = z.infer<typeof filteredIssuesRequestSchema>
export type GetGroupedIssuesRequest = z.infer<typeof groupedIssuesRequestSchema>
Which results in a:
Copy code
type GetFilteredIssuesRequest = {
    status?: ("open" | "in progress" | "done" | "in review" | "canceled")[] | null | undefined;
    priority?: ("low" | "medium" | "high" | "urgent")[] | null | undefined;
    projectId?: number | null | undefined;
    parentIssueId?: number | ... 1 more ... | undefined;
}

type GetGroupedIssuesRequest = {
    field: "status" | "priority" | "projectId";
}
a
Thanks! I donโ€™t see anything obvious, so it would be best if you could provide a minimal reproduction repository so I can recreate this fully ๐Ÿ‘.
k
@Austin I can give you access to the repository, it's an early project experiment, so nothing special there yet. ๐Ÿ™‚ Can I have your GitHub handler?
a
It would actually be more helpful if you created a second repository with all the irrelevant bits removed. It makes debugging much quicker!