@ auth0 / angular-jwt:装饰器中不支持函数调用,但已调用“ JwtModule”

问题描述

我将Angular项目从9升级到了10(并将angular-jwt升级到了5.0.1版),而我构建的Angular库不再能编译了。相反,它返回错误

错误:“库模块名称”的模板编译期间发生错误 装饰器不支持函数调用,但已调用'JwtModule'。

我没有更改与JwtModule相关的代码,但是由于某种原因,我的库模块的导入中不再接受JwtModule.forRoot(<my config object>)。如果删除.forRoot(...)部分,则库会编译。但是然后,我想念我的JwtOptions配置。据我所知,使用.forRoot()是确保JwtModule为单例并且在所有地方应用相同配置的唯一方法

这是升级到Angular 10时实现中断的实现问题吗?还是我只是缺少一些东西?

我的图书馆模块

// the JWT module,for ensuring the JWT is managed properly
import { JwtModule,JwtModuleOptions } from '@auth0/angular-jwt';
// ... more imports in reality

// exported function for the jwt service..
export function jwtTokenGetter() {
  return localStorage.getItem('access_token');
}
const jwtConfig : JwtModuleOptions = {
  config: {
    headerName: 'Jwt-Authorization',tokenGetter: jwtTokenGetter,allowedDomains: [ 'api.vvtupos.nl','login.vvtupos.nl' ]
  }
};

@NgModule({
  declarations: [
    // ... more declarations in reality
  ],imports: [
    JwtModule.forRoot(jwtConfig)
    // ... more imports in reality
  ],exports: [
    // ... more exports in reality
  ]
})
export class ClubcoreLibraryModule {
  constructor(){
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)