Open Forfold opened 1 year ago
It looks like if I do an undefined check beforehand I get the typings to do the following
const payload = user?.getSignInUserSession()?.getAccessToken().payload
const groups = payload ? payload['cognito:groups'] : []
though it looks like the keys on payload are still set to any
from within amazon-cognito-identity-js
@reesscot would this issue be better suited for the amazon-cognito-identity-js
repo, since that's where the CognitoUser
interface is located (what CognitoUserAmplify
extends)?
@Forfold Yes, these types should be updated in the JS repo. Transferring this ticket over there.
We have published an RFC on our plan for improving TypeScript support in Amplify JS & would love to get your feedback & suggestions!
On which framework/platform would you like to see this feature implemented?
React
Which UI component is this feature-request for?
Authenticator
Please describe your feature-request in detail.
When using
Authenticator
with Typescript, I'm seeing the following typing:However, when I ask for the
user
object fromAuthenticator
I'm seeing many more fields not present on the type- especially the payload that I need to use to determine if a user is an admin or not:Please describe a solution you'd like.
Would it be possible to add more a complete typing for the
Authenticator
user
object?I only found out I needed to use the path
u.signInUserSession.accessToken.payload['cognito:groups']
to grab the user groups from this issue https://github.com/aws-amplify/amplify-js/issues/4306We love contributors! Is this something you'd be interested in working on?