I've been searching and came across this answer. It didn't work for me, maybe they updated syntax!!
What I used was just adding as
followed by any of my existing table names, but please note this won't be good if the table names get changed.
Also union types doesn't work, because typescript won't be able to narrow down the type and will throw another error!
You can still use as any
like so:
await (prisma[tableName] as any).findUnique({..})