Answer the question
In order to leave comments, you need to log in
How to add a new Request type to typing Express?
I want to add a new type Request. That is, there is a regular Request, but I want to make my own with a new field.
There is an easy way to do
declare module 'express-serve-static-core' {
interface Request {
auth?: {
test: string
}
}
}
declare module 'express-serve-static-core' {
interface AuthorizedRequest<P extends Params = ParamsDictionary> extends Request<P> {
auth: {
test: string
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question