Using
"@types/express-serve-static-core": "4.17.13"
,
the augmentation of express-serve-static-core
is functioning properly:
import { Request, Response, NextFunction } from 'express'
import { PrismaClient } from '@prisma/client'
import express from 'express'
declare module 'express-serve-static-core' {
interface Request {
prisma: PrismaClient
}
}
const bodyParser = require('body-parser')
const app = express()
const port = 8000
const prisma = new PrismaClient()
app.use((req: Request, res: Response, next: NextFunction) => {
req.prisma = prisma
next()
})
After updating to
"@types/express-serve-static-core": "4.17.14"
, the express
server stops working and displays this error:
Error: Property 'prisma' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs>'.ts(2339)