PrismaP
Prisma2y ago
7 replies
Lady Gaga

Prisma with Accelerate TypeScript error

When I'm using Prisma with Accelerate, the Prisma types are not generated for the Accelerate extension. Trying to use cacheStrategy results in TS showing the following error:
Type '{ ttl: number; }' is not assignable to type 'never'.ts(2322)


I'm using SvelteKit and have the following setup:
src/app.d.ts:
import type { PrismaClient } from "@prisma/client";
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces

declare global {
  namespace App {
    // interface Error {}
    // interface Locals {}
    // interface PageData {}
    // interface Platform {}
  }
  var prisma: PrismaClient;
}

export {};


src/lib/server/prisma.ts:
import { PrismaClient } from "@prisma/client";
import { withAccelerate } from "@prisma/extension-accelerate";

declare global {
  var prisma: PrismaClient;
}

const prisma = global.prisma || new PrismaClient().$extends(withAccelerate());
global.prisma = prisma;

export default prisma;


How can I fix this?
Was this page helpful?