Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use TokenType.Aad since 0 is equal to false #31

Open
carlosedof opened this issue Jul 6, 2020 · 1 comment
Open

Cannot use TokenType.Aad since 0 is equal to false #31

carlosedof opened this issue Jul 6, 2020 · 1 comment

Comments

@carlosedof
Copy link

TokenType.Aad represents a 0 and this prop cannot be passed as a string.
0 when evaluated by JS is false.
Inside component implementation there is a function called getConfigFromProps that validates tokenType sent to the component, as it follows:
tokenType: tokenType || TokenType.Embed,
This always fails if left side of the expression is 0.

Maybe you could change Aad to 2 or allow to pass string as tokenType param.

Thanks.

@AaronJPA
Copy link

same problem here.

this also happens with Permissions.Read (= 0).

I patched using ?? (nullish coalescing) instead of the || (logical OR).

permissions: permissions ?? Permissions.All,
tokenType: tokenType ?? TokenType.Embed,
type: embedType ?? 'report'

but this is a relatively new feature in ES, so it depends on which versions of node/typescript/target es/etc you are using.

if you can't use ??, you may use something like:

permissions: (permissions != (null || undefined)) ? permissions : Permissions.All,
tokenType: (tokenType != (null || undefined)) ? tokenType : TokenType.Embed,
type: (embedType != (null || undefined)) ? embedType : 'report'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants