【发布时间】:2022-11-15 16:54:24
【问题描述】:
我有这个lib.d.ts文件
import { Users } from '@prisma/client';
declare global {
namespace Express {
interface User extends Users {}
}
}
我有这个护照.ts在同一个文件夹中,其中用户是类型快递.用户
passport.serializeUser((user, done) => {
done(null, user.id);
});
IDE 没有抱怨它,但是当我运行应用程序时出现此错误:
error TS2339: Property 'id' does not exist on type 'User'.
这是我的 tsconfig.json :
{
"compilerOptions": {
"target": "es2016",
"lib": ["es6"],
"module": "commonjs",
"rootDir": "src",
"resolveJsonModule": true,
"allowJs": true,
"outDir": "build",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"skipLibCheck": true,
}
}
这是从 tsconfig json 到文件的路径:
- src/config/passport/passport.ts
- src/config/passport/lib.d.ts
为什么会发生这种情况,我已经尝试修复此错误 2 天了。
【问题讨论】:
标签: javascript typescript