I am working on an Express application where I need to extend the Request interface to include custom properties for user and admin. Here’s my custom interface:
enter image description here
This setup worked fine until I installed the @types/passport-google-oauth20 package. After installing it, TypeScript started throwing errors, and I suspect it is due to conflicts between my CustomRequest interface and the global augmentation provided by @types/passport-google-oauth20.
The Profile type imported from passport-google-oauth20 has predefined properties like id, which conflicts with my custom id property. For example:
Profile.id is a string (Google profile ID), but my user.id refers to my application’s user ID.
I tried using intersection types (&), but the conflicts remain, and my CustomRequest interface doesn’t work as expected.
But it didn’t solve the problem and still throwing errors. What should i do ?
Aswin Ambalathara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.