Struggling with Typescript lint errors when using dynamic table names and Prisma. I have the following code:
type Mode = 'category' | 'ingredients';
let mode: Mode;
mode = req.query.mode as Mode;
if(mode === 'category'){
const table = 'category';
const lookup = 'categoriesOnDishes';
const lookupItemIdKey = 'categoryId';
}else if(mode === 'ingredients'){
const table = 'ingredient';
const lookup = 'ingredientsOnDishes';
const lookupItemIdKey = 'ingredientId';
}
let lookupData = await prisma?.[lookup].findMany({
where : {
dishId : did
}
})
the error is:
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'
How to fix this issue.
Thanks in advance.
