我收到以下错误。请帮帮我。
controller.ts(8,8): error TS2339: Property 'user' does not exist on type 'Request'.
import * as express from 'express';
class Users{
public showUser(
req: express.Request,
res: express.Response,
next: express.NextFunction
) {
return req.user;
}
}
const users = new Users();
export = {
showUser: users.showUser
}
// Extend the Express interface with declaration merging
import { User } from './api';
declare namespace Express {
export interface Request {
user: User;
}
}
export class User {
'userId': string
}
如果我在express.custommerge.d.ts中添加import { User } from './api';
并添加any
而不是User
答案 0 :(得分:0)
如果我在
中进行以下更改,则有效HashTable