@types/express-session 不起作用。知道为什么吗?
@types/express-session doesn't work. Any idea why?
我在我的 web 应用程序的后端使用 typescript,并且我已经合并了 express-session。我有 @types/express 和 @types/express-session 但不幸的是我不断收到类型错误:
Property 'session' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
有谁知道发生了什么事吗?
版本:
"express": "^4.17.1",
"express-session": "^1.17.1",
"@types/express": "^4.17.11",
"@types/express-session": "1.17.0",
示例代码:
const auth_data: authSuccess|authError = await discordClient.exchangeCodeForTokens(String(disCode));
if(!auth_data) {throw new Error('Could not Authorize!')}
req.session.oauth = auth_data;
最后一行会抛出类型错误:Property 'session' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
问题是我这样导入了快速会话:
const session = require('express-session')
而不是像这样:
import session from 'express-session';
这完全有道理。我不知道为什么我不想看看我的进口商品!
我在我的 web 应用程序的后端使用 typescript,并且我已经合并了 express-session。我有 @types/express 和 @types/express-session 但不幸的是我不断收到类型错误:
Property 'session' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
有谁知道发生了什么事吗?
版本:
"express": "^4.17.1",
"express-session": "^1.17.1",
"@types/express": "^4.17.11",
"@types/express-session": "1.17.0",
示例代码:
const auth_data: authSuccess|authError = await discordClient.exchangeCodeForTokens(String(disCode));
if(!auth_data) {throw new Error('Could not Authorize!')}
req.session.oauth = auth_data;
最后一行会抛出类型错误:Property 'session' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
问题是我这样导入了快速会话:
const session = require('express-session')
而不是像这样:
import session from 'express-session';
这完全有道理。我不知道为什么我不想看看我的进口商品!