Auth0 Home Blog Docs

Jwt-decode in TypeScript

typescript

#1

Working through the sample code on the Auth0 SPA. I’m working in TypeScript, and am having issues as the token returned by jwt-decode is of type {} this means that the calls to the token parameters don’t resolve.

function getTokenExpirationDate(encodedToken: any) {
let token = jwt_decode(encodedToken);
if (!token.exp) { return null; }

const date = new Date(0);
date.setUTCSeconds(token.exp);

return date;

}

Is the type for this exposed, and is so, what is it?