'Passport req.logout() function not found by the compiler
I'm trying to implement Google OAuth 2.0 with Passport in my TypeScript NodeJs app. I managed to log the user in, but I'm stuck at the logout part because my compiler does not seem to recognize the logout() method (logOut did not work either).
router.get('/logout', function (req, res){
req.logout();
});
Error: Property 'logout' does not exist on type 'Request<{}, any, any, ParsedQs, Record<string, any>>'.ts(2339)
I also want to mention that I have encountered some other issues while trying to access properties of the req parameter when giving it the type Request, so I gave up on the type. I think it is because of TypeScript, but I don't want to write my app using JS, so any advice on that would be appreciated.
My package.json dependencies:
"dependencies": {
"@types/express": "^4.17.13",
"@types/express-serve-static-core": "^4.17.28",
"axios": "^0.25.0",
"body-parser": "^1.19.1",
"connect-mongo": "^4.6.0",
"dotenv": "^14.3.2",
"express": "^4.17.2",
"express-passport-logout": "^0.1.0",
"express-session": "^1.17.2",
"mongoose": "^6.1.8",
"passport": "^0.5.2",
"passport-google-oauth20": "^2.0.0",
"passport-local": "^1.0.0",
"ts-node": "^10.4.0",
"ts-node-dev": "^1.1.8",
"tslint": "^6.1.3",
"typescript": "^4.5.5"
}
my tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strictPropertyInitialization": false,
"noImplicitReturns": true,
"noImplicitAny": false,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2017",
"lib": [
"es2018",
"dom"
],
"strict": false,
}
}
Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
