This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Error when build: Property 'xxx' does not exist on type 'User'. #221
Comments
Seems like the problem is an update on the @types/passport declaration: DefinitelyTyped/DefinitelyTyped@91c229d#comments I fixed it by augmenting with a file in
|
Thanks for this. |
Let me know if that works: import express from 'express';
import { UserDocument } from '../models/User';
declare module 'express' {
export interface User extends UserDocument {}
export interface Request {
user?: User;
}
}
`` |
peterblazejewicz
added a commit
to peterblazejewicz/TypeScript-Node-Starter
that referenced
this issue
Sep 4, 2019
In case you get the Duplicate Key Error, make sure you use // eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as MongoUserSchema from '../../src/mongo/models/User';
declare global {
namespace Express {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface User extends MongoUserSchema.User {}
}
} TypeScript Rules! |
This is the solution that worked for me: export {};
declare global {
namespace Express {
interface User {
username: string;
id?: string;
profile?: any;
// Add whatever you're missing
}
}
} You can place this within a |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: