Angular2-jwt: Function expressions are not supported in decorators in '傻0'

Created on 15 May 2018  路  3Comments  路  Source: auth0/angular2-jwt

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 srcappcomponentsloginlogin.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 '';
}
}
})

Most helpful comment

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.

All 3 comments

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.

That works, thanks.

Important:

This wont work:

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

This will work:

export function myFunc(): boolean { return true; }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmitrybz picture dmitrybz  路  4Comments

fabiodomingues picture fabiodomingues  路  5Comments

getglad picture getglad  路  5Comments

leosvelperez picture leosvelperez  路  5Comments

kolkov picture kolkov  路  3Comments