#(Guard) metatype is not a constructor

5 messages · Page 1 of 1 (latest)

hallow tiger
#

i seem to encounter some issue with guards i never had seen before where i get metatype is not a constructor

@Injectable()
export class SessionGuard implements CanActivate {
  private readonly logger = new Logger(SessionGuard.name)
  async canActivate(context: ExecutionContext) {
    const req = context.switchToHttp().getRequest()
    this.logger.debug(req.user)
    this.logger.debug(req.isAuthenticated())
    return true
  }
}

PLZ somebody tell me why this could happen or what this means 😭

hallow tiger
#

Guard; metatype is not a constructor

#

(Guard) metatype is not a constructor

tough needle
#

Usually when there's an error like that it's because the guard is coming in as undefined

hallow tiger