본문 바로가기

Web/Node.js & Nest.js

[nestjs] 식으로 호출된 경우 메서드 데코레이터의 서명을 확인할 수 없습니다. 런타임에서는 2 인수를 사용하여 데코레이터를 호출하지만 데코레이터에는 3이(가) 필요합니다.ts(1241)

import { Controller, Get, Session, UnauthorizedException } from '@nestjs/common';
import { AuthService } from './auth.service';
import { user_account } from '../../common/types/user.types';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Get('check-login')
  async checkLoginState(@Session() session: Record<string, any>): Promise<user_account> {
    const sessionId = session.sessionID;
    if (!sessionId) {
      throw new UnauthorizedException('로그인을 진행하여 주세요.');
    }
    return this.authService.checkLoginState(sessionId);
  }
}

맞는 코드를 작성하였는데도 @Get('check-login') 부분에서에서 오류라 인식하였다.

 

해결 방법

> 터미널에 npx tsc 입력

 

tsconfig.json 수정 후 갱신하지 않아서 오류가 발생하였던 것 같다..