带有或不带有tsconfig目标es5的NestJS和TypeORM问题

Atu*_*ary 6 node.js typescript webpack typeorm nestjs

根据NestJS身份验证教程,我复制粘贴了JwtStrategy该类,但是该类在构建时抛出错误

类代码是

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor(private readonly userRepo: UserRepository) {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      secretOrKey: 'secretKey'
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

并在tsconfig.json文件中使用target = es5,我得到了错误

在此处输入图片说明

现在,如果我将目标更改为es6,错误消失了,但是键入多对多关系开始抛出错误

TypeORM类用户获得令牌,而Token类获得用户,并在下面抛出错误

在此处输入图片说明

我创建了存储库以重现链接上的错误

运行以下命令以查看错误

ng s --project=api
Run Code Online (Sandbox Code Playgroud)

Kim*_*ern 1

您正在混合 Nest v5 和 Nest v6,尽管不同的主要版本不能保证正确互操作,例如:

"@nestjs/core": "5.5.0",
"@nestjs/jwt": "^6.0.0",
Run Code Online (Sandbox Code Playgroud)

请按照迁移指南将所有依赖项更新@nestjs到版本 6 。