DEV Community

JunoLee1
JunoLee1

Posted on

About my mistakes

Hi
My team started to new project which is fashion shopping web. I've played role of Authentication System.
So I made Routes and Controller, Services, repository.

  1. Property 'email' does not exist on type 'Prisma_UserClient', Property 'password' does not exist on type 'Prisma_UserClient'.

its means that expected return type different actual return type.
therefore, I checked user model column and DTO, But It wont be problem. when I googled, everyone mentioned re-generate prisma and check the type in prisma. thats it. So I asked my mentor about the problem. It was simple and easy problem.

my origin code was

// login controller
async login (req:Request, res:Response, next: NextFunction ) {
  ...
  const user = this.repository.login(email)
 ...
 const isMatched = await bcrypt.compare(password, user.password)

}
Enter fullscreen mode Exit fullscreen mode

Yes i was missed await in constance of user ... LOL.

// login controller
async login (req:Request, res:Response, next: NextFunction ) {
  ...
  const user = await this.repository.login(email)
 ...
 const isMatched = await bcrypt.compare(password, user.password)

}
Enter fullscreen mode Exit fullscreen mode
  1. Argument of type 'string | undefined' is not assignable to parameter of type 'false.

the error expected return value is boolean but return type is string?.
I was tried to make jwt-Verify callback as Type of done. I reckoned callback fn consisted with error obj, user's obj as boolean value. this is because in the deserialiseUser function, the user return value should be boolean. However it must have null for error, user.id in serialiseUser. I could not recognised making new type.

Top comments (0)