angular2-jwt icon indicating copy to clipboard operation
angular2-jwt copied to clipboard

Function expressions are not supported in decorators in 'ɵ0'

Open nickraphael opened this issue 8 years ago • 3 comments

I'm getting this error when I do an aot build.

ERROR in Error during template compile of 'LoginModule' Function expressions are not supported in decorators in 'ɵ0' 'ɵ0' contains the error at src\app\components\login\login.module.ts(23,22) Consider changing the function expression into an exported function.

I suspect it's because I have a lambda in my module... JwtModule.forRoot({ config: { tokenGetter: () => { return ''; } } })

nickraphael avatar May 15 '18 05:05 nickraphael

Have you tried to specify the tokenGetter as following?

export function jwtTokenGetter() {
  return ...;
}

JwtModule.forRoot({
  config: {
    tokenGetter: jwtTokenGetter
  }
})

Otherwise you can try using a custom options factory, see README.md.

OckePocke avatar May 16 '18 21:05 OckePocke

That works, thanks.

nickraphael avatar May 16 '18 22:05 nickraphael

Important:

This wont work:

export const myFunc = (): boolean => true;

This will work:

export function myFunc(): boolean { return true; }

odahcam avatar Oct 09 '18 13:10 odahcam