[英]cannot use d.ts file to load declaration merging
works fine perfectly when these are in the same file.当它们在同一个文件中时,效果很好。
declare module "express-session" {
interface SessionData {
userId: number;
}
}
static async loginUser(req: Request, res: Response) {
const { email, password } = req.body;
req.session!.userId = 1;
return res.send("login");
}
However, if I seperate these files into,但是,如果我将这些文件分成,
index.d.ts index.ts索引.d.ts 索引.ts
then it shows that userId does not exist within SessionData or Partial.然后它表明 SessionData 或 Partial 中不存在 userId。
Why is this so?为什么会这样?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.