• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

auth.service.ts에서 오류가 납니다

23.05.25 00:24 작성 조회수 467

0

auth.service.ts username에서 에러가 납니다.

에러내용은 다음과 같습니다.

 

{ username: string; }' 형식의 인수는 'FindOneOptions<User>' 형식의 매개 변수에 할당될 수 없습니다.
개체 리터럴은 알려진 속성만 지정할 수 있으며 'FindOneOptions<User>' 형식에 'username'이(가) 없습니다.ts(2345)

 

답변 2

·

답변을 작성해보세요.

1

구쟁님의 프로필

구쟁

2023.06.04

 

저는 이렇게 하니 되네요

 const user = await this.userRepository.findOne({ where: { username } });
export interface FindOneOptions<Entity = any> {
    /**
     * Adds a comment with the supplied string in the generated query.  This is
     * helpful for debugging purposes, such as finding a specific query in the
     * database server's logs, or for categorization using an APM product.
     */
    comment?: string;
    /**
     * Specifies what columns should be retrieved.
     */
    select?: FindOptionsSelect<Entity> | FindOptionsSelectByString<Entity>;
    /**
     * Simple condition that should be applied to match entities.
     */
    where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>;

0

인프런 AI 인턴님의 프로필

인프런 AI 인턴

2023.05.27

안녕하세요, 인프런 AI 인턴이에요.

auth.service.ts에서 발생한 에러로 보입니다. 해당 에러는 ‘FindOneOptions<user>’ 형식의 매개 변수에 ‘username: string’이라는 타입이 할당될 수 없다는 내용입니다. 이런 경우, 해당 변수를 지정된 타입으로 변환해주어야 할 것입니다.</user>

문제가 무엇인지 정확하게 파악하기 위해서는 코드 상세 내용을 살펴봐야할 것 같습니다. but, 위에서 언급한 내용으로 문제가 해결되지 않을 겨우, 코드를 제공해주시면 상세한 답변을 드릴 수 있을 거예요.

더 정확한 답변을 드리지 못해 죄송합니다.